com-object & getting pid

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lnp80
Forum Newbie
Posts: 7
Joined: Thu Mar 31, 2005 1:26 pm

com-object & getting pid

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can search in the output from 'tasklist' for python. Would likely be the highest PID.
Post Reply