Page 1 of 1

com-object & getting pid

Posted: Mon Apr 11, 2005 12:44 pm
by lnp80
Hello

I am using the following code for starting a script (my_script.py) and having it running in the background (without halting the initiating php-script)

my php-script:

Code: Select all

$cmd = "python my_script.py";
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($cmd, 1, false);
What i need is some way to obtain the processID of the python-script I have started in the run-method or some way of naming the process who runs this python-script. I am using windows XP, and every python-scripts i run just get the process name python.exe (and not the name of the python script).

I need to do one of these two things to be able to see if the background python script is running at an instance of time and to be able to kill it.

I hope someone can help me.
Thanks in advance

Posted: Thu Apr 14, 2005 5:23 pm
by feyd
you can search in the output from 'tasklist' for python. Would likely be the highest PID.