使用Python,我如何获得该进程的运行进程和exe名称?

时间:2011-08-08 03:01:29

标签: python windows process

假设我有一个exe运行,其名称为myexe.exe。在Windows上,我可以在Process Explorer中看到myexe.exe的过程。使用Python,我如何获取myexe.exe的进程ID并将其关闭?

2 个答案:

答案 0 :(得分:2)

如果您使用wmi(Windows Management Instrumentation模块),则可以通过wmi服务执行此操作。在这里查看examples以获取进程名称并终止使用进程ID。

答案 1 :(得分:0)

在Windows上执行此操作的最佳方法是使用PyWin32(http://sourceforge.net/projects/pywin32

请查看以下代码示例:http://coding.derkeiler.com/Archive/Python/comp.lang.python/2007-10/msg00717.html

这可能正是您所需要的。