exec method WMI

future_retro at yahoo.co.uk future_retro at yahoo.co.uk
Wed Jul 13 12:45:48 EDT 2005


Hi, I'm trying to use the AddPrinterDriver method of
Win32_PrinterDriver to create a new..... print driver.  I can't get my
head round how I need to do this.  So far I have

import win32com.client
WBEM =
win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\"
+ "." + r"\root\cimv2")
WBEM.Security_.Privileges.AddAsString("SeLoadDriverPrivilege")
drv = WBEM.Get("Win32_PrinterDriver").SpawnInstance_()
drv.Properties_('Name').Value = "Marcs Printer 2550"
drv.Properties_('SupportedPlatform').Value = "Windows NT x86"
drv.Properties_('Version').Value = "3"
drv.Properties_('DriverPath').Value = 'C:\\test\\HPZPP034.DLL'
drv.Properties_('InfName').Value = 'C:\\test\\hpc2550d.inf'
method = drv.Methods_('AddPrinterDriver')
InParms = method.InParameters
InParms.Properties_.Item('DriverInfo').Value = drv
drv.ExecMethod_('AddPrinterDriver',InParms)

I'm using spawninstance to create a new object and then editing the
properties of it.  I'm then setting the InParameters for the method to
be the new object.  When executing the method I get SWbemObjectEx
object not found.

I think I am not setting the DriverInfo correctly, should it be an
object?  The MSDN site doesn't say what DriverInfo should be.

Any help would be grand.

Thanks, MW.




More information about the Python-list mailing list