I'm writing a Python script that gets information on processes (PID, Command Line, etc.) running on a PC.
On my Windows 7 PC I can use 'wmic' and use the output from that:
output = subprocess.Popen(['wmic process get creationdate,commandline,processid'], stdout=subprocess.PIPE, shell=True).communicate()[0]
Example of the info I can get from this output:
PROCESS PID START TIME COMMAND: blah.exe 1234 Thu Jun 06 15:33:40 2013 C:\blah\blah.exe -a -b blah.txt
This gives me all the info I need... HOWEVER not all machines will let me use 'wmic' as I'm not an Administrator.
I can use 'tasklist', but it doesn't give me the 'commandline' info that wmic does.
I can't use 'psutils' (or the 'wmi' module), as it's not installed on any of the PCs I need it to work on, and I don't want to have to get admin install modules on all these PCs
Any ideas on how I can get the above process information using standard Python 2.6?
Thanks in advance, Nick
PYTHON 2.6 on Windows XP/7
=====================================================================
EDIT (12 June 2013):
I'm trying to do as suggested below, but having trouble... I've put the psutil directory (psutil-0.7.1) in the same directory as my script and added the following to my script:
path = '.\psutil-0.7.1'
sys.path.append(path)
import psutil
I now get the below error:
Traceback (most recent call last):
File "C:\Users\nickw\Desktop\ProcessMonitor\ProcessMonitor_MODPS2.py", line 21, in <module>
import psutil
File ".\psutil-0.7.1\psutil\__init__.py", line 77, in <module>
import psutil._psmswindows as _psplatform
File ".\psutil-0.7.1\psutil\_psmswindows.py", line 15, in <module>
import _psutil_mswindows
ImportError: No module named _psutil_mswindows
Any idea what I'm doing wrong?