【问题标题】:Using Python, how can I obtain the running process and the exe name for that process?使用 Python,如何获取正在运行的进程和该进程的 exe 名称?
【发布时间】:2011-08-08 03:01:29
【问题描述】:

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

【问题讨论】:

标签: python windows process


【解决方案1】:

如果您使用wmi(Windows Management Instrumentation 模块),您可以通过 wmi 服务来完成。在此处查找 examples 以获取进程名称并使用进程 ID 终止。

【讨论】:

    【解决方案2】:

    在 Windows 上最好的方法是使用 PyWin32 (http://sourceforge.net/projects/pywin32)

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

    这可能正是您所需要的。

    【讨论】:

    • 实际上,我期待一种使用 ctyps 而不是 3rd-party 模块的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多