I'm trying to get all the processes and applications that are currently running using Python on Windows 7
I'm currently running Windows 7, and I'd like to be able to check whats going on programaticly using Python. How would I go a开发者_StackOverflowbout getting all the currently runing processes and applications?
Get the WMI module and then check out this cookbook for some simple examples. Note this is not the most efficient way, talking to the win32 api with ctypes is faster but much much more legwork.
To list all currently running processes:
import wmi
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
The psutil module may be helpful. For instance:
import psutil
[psutil.Process(pid).name for pid in psutil.get_pid_list()]
精彩评论