[Sergey] | Yes, I had run it. | | And, just now I updated python, pythonwin and wmi.py to | latest version. And got: | | >>> a=wmi.WMI() | >>> a.Win32_Process.Create(CommandLine="notepad.exe") # | --- it works | >>> a.Win32_Process.new().Create(CommandLine="notepad.exe") | # it still fail | Traceback (most recent call last): | File "<stdin>", line 1, in ? | File "wmi.py", line 361, in __call__ | handle_com_error (error_info) | File "wmi.py", line 208, in handle_com_error | raise x_wmi, "\n".join (exception_string) | wmi.x_wmi: -0x7ffdfff7 - Exception occurred. | Error in: SWbemObjectEx | -0x7ffbefff - Generic failure | | Without 'new' everything works. And does everything I need from it.
Yes, I think the simple answer is: don't use .new unless you're sure you need to. When I wrote the wmi module originally, I misunderstood the use of SpawnInstance_ (which is the method behind .new). To create a process, or a share, or anything which has a .Create method, use the .Create method. Use .new only for things like Win32_ProcessStartup, as in this example here: http://timgolden.me.uk/python/wmi_cookbook.html#run-process-minimised where the instance is created only to pass as a parameter into the .Create method of the Win32_Process. I've updated the module docstring for the next release, and have changed the cookbook examples which used .new where they shouldn't have, so thanks for highlighting the deficiency. | And, I have another question. Is there way to access WMI from linux? Not using this module, which is very Windows-specific; there was some work recently on WBEM (which is the industry standard behind WMI) on Linux, but I've not tried to use it myself: http://pywbem.sourceforge.net/ 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 ________________________________________________________________________ -- http://mail.python.org/mailman/listinfo/python-list