Michael Foord wrote: > I recently blogged about how listing all running processes is easy with > IronPython [1].
> Can anyone suggest a better solution? (DISCLAIMER: I didn't write this, > my colleagues 'borrowed' it from the intarwebz.) (Hmmm. Bit defensive there, Mr F.... :) [pywin32] > # check if AVG and Thunderbird are running > import win32pdhutil > for procName in ['avgwa.dat', 'avgw', 'thunderbird', "THUNDE~1"]: > try: > win32pdhutil.GetPerformanceAttributes('Process','ID Process', > procName) > except: > pass > if win32pdhutil.FindPerformanceAttributesByName(procName): > print "Pylint error found: Please shut down %s" % procName > win32pdhutil.ShowAllProcesses() > sys.exit(1) [IronPython] > from System.Diagnostics import Process > > procs = Process.GetProcesses() > print "All running processes:" > print '\n'.join(proc.ProcessName for proc in procs) http://timgolden.me.uk/python/wmi_cookbook.html#running_processes [WMI using pywin32] import win32com.client wmi = win32com.client.GetObject ("winmgmts:") procs = wmi.InstancesOf ("Win32_Process") print "\n".join (proc.Properties_ ("Caption").Value for proc in procs) [WMI using wmi module] import wmi procs = wmi.WMI ().Win32_Process () print "All running processes:" print "\n".join (proc.Caption for proc in procs) In fact, putting your subject line plus "Python" into Google, these solutions (in different forms) appear third and sixth in the results list. TJG _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32