We have a PHP (5.5.15) script on WAMP with this:
$wsh_shell = new COM("WScript.Shell");
$retval = $wsh_shell->Run($batch_file_name, 0, false);
$batch_file_name is simply a .bat file that runs another PHP file. 95% of the time this works perfectly and it is able to run the file. The other 5% it just fails to run.
Is there any way to get more information as to why the process failed to run? $retval above only contains 1 or 0. Does wscript.shell log failures somewhere? Is there some other log that might give me a clue as to why these failures occur?
I was able to work around the issue by having the script use the Windows Task Scheduler to start a new instance of itself. The script has a loop that runs for about 30 minutes. It then reads in a config file and checks for a "respawn" command. If it's true, the script will now use schtasks command line to create a 1-time task to start itself again in 3 seconds. It's been running for several hours with no issues.