I'm rewriting Mark's answer for Windows and so far I've come up with this:
// Escape character for Windows is: ^
$shellCmd = 'start /B cmd /c ' . escapeshellcmd($cmd) . ' ^>"'.$outputfile. '"';
// note that exec was like 40 times slower than popen & pclose
pclose(popen($shellCmd, "r"));
There's tasklist
command on Windows but I don't know how to find out the PID of my process. To be punctual I'm looking for PID of the process that is opened via popen.
Can you help me? Thanks!
Note: I'm not sure what this code does with error output but in my case it doesn't matter.