XP exec background process

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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 >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.


Re: XP exec background process


I think what you've done was to use /b instead of /B , not sure, i am
Linux user. Also this is a real solution, however needs something for
download but not a problem i think:




Re: XP exec background process

Drakazz wrote:
Quoted text here. Click to load it

Thanks! I used the COM method from--


--because I only need this script to run on Windows.  BTW, Windows does  
not care about capitalization on the command line.

Re: XP exec background process

Quoted text here. Click to load it

On DOS and Windows systems...

When working with paths and filenames, such items are case-insensitive.
DOS used to save all paths and filenames as 100% uppercase. However,
Windows will save the files in mixed case, even though the "file system"
treats it as case insensitive (providing only the visual benefits of upper
and lower case).

Passing switches/parameters on the command-line for different commands
may or may not be case-sensitive.

Some compilers are case-sensitive. Some tools are case-sensitive.

ntsd.exe command line parameters...
  -g ignores initial breakpoint in debuggee
  -G ignores final breakpoint at process termination

ml.exe assembler...
  /Fr[file] Generate limited browser info
  /FR[file] Generate full browser info

As far as the file system goes, you can type ml.exe any way you like.

As far as the switches go, the application processes the switches, and
you just don't know unless you know.

Hope this helps.

Jim Carlock
+"North Carolina Swimming Pools"+http://aquaticcreationcnc.com
Post replies to the group.

Re: XP exec background process

Jim Carlock wrote:
Quoted text here. Click to load it

I meant references to Windows file names and options for Windows  
built-in commands (unless you can point out a counter-example).

I summarized the methods here:

Site Timeline