List Running Programs under Windows
Joe Francia
usenet at soraia.com
Thu May 15 01:38:50 EDT 2003
Joe Aspelund wrote:
> I am programming for Windows (Windows XP more specifically) and I am
> trying to genrate a list of the currently running programs. Similar to
> the "Processes" tab of "Task Manager". A little clarification of the
> program: I want it to change the way it runs depending on other
> programs that are currently running. I just need to generate a list of
> sorts.
> Thanks for any assistance.
(posted and mailed)
I use WMI to get such info (assumes you have win32all or ActiveState's
Python installed):
## begin script ##
from win32com.client import GetObject
# dot (.) means local computer
# you can also specify the name of a remote computer
wmiObj = GetObject(r'winmgmts:\\.\root\cimv2')
procinfo = wmiObj.ExecQuery('Select * from Win32_Process')
for proc in procinfo:
print proc.Name #gives names of process, i.e., EXPLORER.EXE
## end script ##
See here for a full list of process properties you can access:
http://www.activxperts.com/activmonitor/windowsmanagement/wmi/samples/os/#Win32_Process.htm
Peace,
jf
More information about the Python-list
mailing list