Hi,

I am interested in scanning the user's process table periodically and
getting the list of running process names as well as their command line
parameters.

For the process names, I am able to get the list of pids using
win32process.EnumProcesses and then use win32api.OpenProcess and
win32process.GetModuleFileNameEx to get the names.  However, I couldn't find
anywhere in the doc that tells me how to get the command line parameters for
them as well.

Then I found the WMI module on
http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes that
seems to do the trick:

import wmi
c = wmi.WMI ()
for process in c.Win32_Process ():
  print process.CommandLine

Is that the most efficient way to get the command line parameters?  My
program will need to scan the process table quite often, so I am trying to
make this operation as lightweight as noticeable.

Thanks,
Patrick
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to