wmi addprinterdriver for remote PC

future_retro at yahoo.co.uk future_retro at yahoo.co.uk
Wed Aug 3 07:23:56 EDT 2005


Hi all, cannot work this one out at all...

import win32com.client
WBEM =
win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\"
+ servername + r"\root\cimv2")
WBEM.Security_.Privileges.AddAsString("SeLoadDriverPrivilege")
drv = WBEM.Get("Win32_PrinterDriver")
drv.Properties_('Name').Value = "HP Color LaserJet 8550 PCL 5C"
drv.Properties_('SupportedPlatform').Value = "Windows NT x86"
drv.Properties_('Version').Value = "3"
drv.Properties_('DriverPath').Value =
"C:\\Printdrivers\\clj8550pcl5cwin2kxp"
drv.Properties_('InfName').Value =
"C:\\Printdrivers\\clj8550pcl5cwin2kxp\\hpbf401i.inf"
method = drv.Methods_('AddPrinterDriver')
InParms = method.InParameters
InParms.Properties_.Item('DriverInfo').Value = drv
drv.ExecMethod_('AddPrinterDriver',InParms)

If servername is "." the driver loads.  If it is a remote machine the
script runs without any errors but no printerdriver is created.  As far
as can tell its not a privilege issue and when running through
pythonwin it looks like the object is created but it doesn't show up in
server properties.  It also runs too quickly so I'm pretty sure its not
doing anything.  I've tried different drivers but no joy.




More information about the Python-list mailing list