Get Process ID and STDOUT running Windows


I have a way to get the Process ID in PHP from a process running in windows …

$com = new COM('WScript.Shell'); $exec = $com->Exec($command); $pid = $exec->ProcessID;

It works very well, my problem is that I ALSO would like to get the STDOUT, and this option doesn’t work

$com = new COM('WScript.Shell'); $exec = $com->Exec($command); $pid = $exec->ProcessID; $output = $exec->StdOut->ReadAll;

How can I get both, namely PID and STDOUT?

Thank you in advance for your help!!

Not sure if exec is working the same way in the COM object, but according to the exec() function, if you give it an array as the second argument, it will return the output in that array.

$exec = $com->Exec($command, $output);


Hi Scott,

What you replied is a mixture between PHP and COM. I do not think that it could will work.

In any case I need both. Process ID and STDOUT.

Thank you for your reply anyway.


Yeah, it was just a guess. Why doesn’t exec() work? It should AFAIK.


PHP exec is not giving me the real Proces ID.

So it is either solve the problem of no output with COM or solve the problem of getting the real PID with exec.

How about just moving to Linux? LOL! :smiley:

I found this.

Not sure it will help.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.