Here is the task:
I have a windows .cmd file that basically navigates to a given directory and runs a given Java program. I can directly run this file and it works just as I expect it to. However, I would like to run it from within a locally hosted php webpage and I would also like for this to be run asynchronously so that my webpage can make use of the data being produced by the java program.
I have tried several things that I was able to find online, including this proposed solution: PHP exec() as Background Process (Windows Wampserver Environment) but nothing seems to work for me.
I was under the impression that a function like this:
<?php
function runAsynchronously($path) {
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($path, 7, false);
unset($WshShell,$oExec);
}
?>
when called with
runAsynchronously('notepad');
(for example), should open notepad and continue to run the php scrip from where it was called. However, nothing seems to happen when I do that. Any suggestions? Beware that I am not experienced with php at all, so I could be unknowingly doing something very stupid :)