python create WMI instances

future_retro at yahoo.co.uk future_retro at yahoo.co.uk
Thu Jun 23 11:08:11 EDT 2005


Heres a script for creating printer ports

import win32com.client
WBEM =
win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\"
+ "." + r"\root\cimv2")
printer = WBEM.Get("Win32_Printer").SpawnInstance_()
printer.Properties_('DeviceID').Value = 'myprinter'
printer.Properties_('DriverName').Value = 'HP 2000C'
printer.Properties_('Location').Value = 'myoffice'
printer.Properties_('Network').Value = 'True'
printer.Properties_('Shared').Value = 'True'
printer.Properties_('ShareName').Value = 'myprintershare'
printer.Properties_('PortName').Value = 'IP_169.254.110.14'
printer.Put_()




More information about the Python-list mailing list