python create WMI instances

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Jun 23 08:51:19 EDT 2005


[future_retro at yahoo.co.uk]
| I've got as far as this.  I don't get any errors but still no
| printer????
| 
| >>> import win32com.client
| >>> WBEM = 
| win32com.client.GetObject(r"winmgmts:{impersonationLevel=imper
| sonate}!\\" + "." + 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.Put_
| 
| Do I need to specify any flags with Put_  ?


Well you certainly need to call it -- printer.Put_ () --
and not just refer to it. But maybe that's just a cut-and-paste
problem. In theory (according to the docs) you could pass a
CREATE_ONLY flag (or something like that) but I don't think
it's strictly necessary. I'd imagine that it would create if
it didn't exist. Check out msdn for more details than you
want to know.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list