How to check if any process is running in task manager using python

I have one function in python that should start when a process appears in the task manager (e.g. proc.exe).
How to control processes running in task manager using python?

+4
source share
2 answers

here is something i adapted from microsoft

  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

There are many good examples here for python and windows.

Update: objItem.ExecutablePath indicates the location of the exe file

+10
source

All Articles