why? [win32com/WMI]

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Mar 2 07:20:26 EST 2006


[Sergey]

| "Tim Golden" <tim.golden at viacom-outdoor.co.uk> wrote in 
| message news:mailman.2569.1141231029.27775.python-list at python.org...
| [Sergey]
| 
| >import wmi
| >c = wmi.WMI (computer="srv", user="Admin at zzz.ru", password="****")
| >pid, retval = c.Win32_Process.Create (CommandLine="notepad.exe")
| 
| Wonderful... It works.
| 
| But I tryed the module, by the sample from help(wmi):
| 
| >>> remote_process = wmi.WMI (computer="pms-dc", user="...", 
| password="...").new ("Win32_Process")
| 
| And got:
| 
| Traceback (most recent call last):
|   File "<stdin>", line 1, in ?
|   File "C:\Python24\Lib\site-packages\wmi.py", line 624, in new
|     return getattr (self, class_name).new (**kwargs)
|   File "C:\Python24\Lib\site-packages\wmi.py", line 539, in new
|     obj.set (**kwargs)
|   File "C:\Python24\Lib\site-packages\wmi.py", line 394, in set
|     handle_com_error (error_info)
|   File "C:\Python24\Lib\site-packages\wmi.py", line 199, in 
| handle_com_error
|     raise x_wmi, "\n".join (exception_string)
| wmi.x_wmi: -0x7ffdfff7 - Exception occurred.
|   Error in: SWbemObjectEx
|   -0x7ffbefdc - Provider is not capable of the attempted operation
| 
| 
| So I decided to fallback to clean COM.

Ah. Apologies; that example is a little out of date. I'll have to
clean up my docs. Obviously, if you want to use "clean COM" then
feel free, but the example you cite above which works for you

pid, retval = c.Win32_Process.Create (...)

does the same thing as the out-of-date example. Although I'm
not entirely sure why that fails. What version of Windows
are you using, by the way? It's possible that I've put something
XP-specific into the module.

<dump>
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wmi
>>> remote_process = wmi.WMI (computer="vogbp364").new ("Win32_Process")

>>>
>>> for i in wmi.WMI ().Win32_OperatingSystem ():
...   print i.Caption
...
Microsoft Windows XP Professional
>>>
</dump>

If you want to go for raw COM, I'm quite happy to give
examples of what you need if you can't work it out; likewise,
I'm happy to work with you to get the wmi module working on
your system if it's something I can easily fix/alter.

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