exec method WMI

Roger Upole rupole at hotmail.com
Wed Jul 13 14:03:31 EDT 2005


You probably need to remove the SpawnInstance_() call.
An abstract WMI class as returned by WBEM.Get should work
for the DriverInfo parm, since the concrete Win32_PrinterDriver
instance is what the AddPrinterDriver call is trying to create.

    hth
        Roger

<future_retro at yahoo.co.uk> wrote in message news:1121273148.010439.70100 at g44g2000cwa.googlegroups.com...
> 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.
> 



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



More information about the Python-list mailing list