views:

87

answers:

1

I have an IronPython script that looks for current running processes using WMI. The code looks like this:

import clr
clr.AddReference('System.Management')
from System.Management import ManagementClass
from System import Array
mc = ManagementClass('Win32_Processes')
procs = mc.GetInstances()

That last line where I call the GetInstances() method raises the following error:

Traceback (most recent call first):
  File "<stdin>", line 1, in <module>
SystemError: Not Found

I am not understanding what's not being found?!? I believe that I may need to pass an instance of ManagementOperationObserver and of EnumerationOptions to GetInstance() however, I don't understand why that is, since the method with the signature Getinstance() is available in ManagementClass.

+1  A: 

I think the only problem is that 'Win32_Processes' is a typo for 'Win32_Process'. This seems to work:

>>> mc = ManagementClass('Win32_Process')
>>> procs = mc.GetInstances()
>>> for p in procs:
...     print p['Name']
... 
System Idle Process
System
smss.exe
(etc)
kvance
you are absolutely right! There is no Win32_Processes ... It works now...
Leo Bontemps