|
Posted by Shailesh Humbad on 03/02/06 11:53
I was trying to exec a background process on XP using PHP CLI, but could
not get it to work. Suppose the command I want to spawn off is "cmd".
On *nix, it is as easy as putting ampersand "&" at the end of the command.
I tried the following on XP without working.
exec("cmd");
exec("cmd >NUL");
exec("cmd /c cmd");
exec("start /b cmd");
I tried many combination, but on each one, PHP waits for cmd to exit
before continuing.
Doing this in Windows script host (cscript) is simple:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd", 0, False
The "False" parameter causes the Run method to continue immediately
without waiting for the command to finish. So I could make my PHP file
exec a VBS file that does the actual background execution of my command.
PHP exec documentation says it will not wait if output of the command is
redirected somewhere, but this didn't seem to work for me. If anyone
has experience in doing something like this on Windows XP SP2, your
thoughts would be appreciated.
Thanks,
Shailesh
Navigation:
[Reply to this message]
|