windows - Remove a network printer with Python's wmi module? -
for starters, here's wmi module i'm referring to.
i've tried many combinations of code, , understand how remove network printers wmic command line, basic understanding on how remove network printers wmi in vb, etc. still can't figure out how in python module.
does have experience this? i'm testing pydev in eclipse, typically on windows 7 machine (which program used along xp), on windows 8.
here's code i've tried:
import wmi c = wmi.wmi () c.win32_printer("\\\\server\\printer").delete
and following error:
wmi.x_wmi_invalid_query: <x_wmi: unexpected com error (-2147217385, 'ole error 0x80041017', none, none)>
a friend (who wishes remain unnamed) found solution!
for printer in c.win32_printer(): if printer.deviceid == "\\\\server\\printer": printer.delete_()
for reason, server name (and possibly printer name) seem case-sensitive, keep eye out that. i'd guess it's because python case sensitive, , it's comparing via python, not wmi.
Comments
Post a Comment