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开发者_JAVA技巧 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
.
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)
精彩评论