How to get PID from PHP function exec() in Windows?
I'm using Pstools which allows you to create a process in the background and capture it's pid:
// use psexec to start in background, pipe stderr to stdout to capture pid
exec("psexec -d $command 2>&1", $output);
// capture pid on the 6th line
preg_match('/ID (\d+)/', $output[5], $matches);
$pid = $matches[1];
It's a little hacky, but it gets the job done