![](/img/trans.png)
[英]How can I check with pywin or win32com.client in python if a certain task is running in task manager?
[英]How to check if some process is running in task manager with python
我在python中有一个函数,当某个进程(例如proc.exe)出现在任务管理器中时,它应该开始运行。
如何使用python监视在任务管理器中运行的进程?
这是一些东西,我改编自微软
import win32com.client strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_Process") for objItem in colItems: print "Name: ", objItem.Name print "File location: ", objItem.ExecutablePath
这里有很多关于python和windows的好例子
更新:objItem.ExecutablePath给出exe的文件位置
试试WMI模块: http : //timgolden.me.uk/python/wmi/cookbook.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.