使用 IronPython 中的 ManagementClass.Getinstances()
我有一个 IronPython 脚本,它使用 WMI 查找当前正在运行的进程。代码如下所示:
import clr
clr.AddReference('System.Management')
from System.Management import ManagementClass
from System import Array
mc = ManagementClass('Win32_Processes')
procs = mc.GetInstances()
我调用 GetInstances()
方法的最后一行引发了以下错误:
Traceback (most recent call first):
File "<stdin>", line 1, in <module>
SystemError: Not Found
我不明白没有找到什么?!?我相信我可能需要将 ManagementOperationObserver
和 EnumerationOptions
的实例传递给 GetInstance()
但是,我不明白为什么会这样,因为具有签名 Getinstance()
的方法在 ManagementClass
中可用。
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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为唯一的问题是“Win32_Processes”是“Win32_Processes”的拼写错误。这似乎有效:
I think the only problem is that 'Win32_Processes' is a typo for 'Win32_Process'. This seems to work: