XP exec background process

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shailesh Humbad

    XP exec background process

    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("W Script.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

  • Drakazz

    #2
    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:






    Enjoy!

    Comment

    • Shailesh Humbad

      #3
      Re: XP exec background process

      Drakazz wrote:[color=blue]
      > http://de2.php.net/manual/en/function.exec.php#56599
      >
      > 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:
      > http://de2.php.net/manual/en/function.exec.php#51599
      >
      > http://de2.php.net/manual/en/function.exec.php#43917
      >
      > http://de2.php.net/manual/en/function.exec.php#35731
      >
      > Enjoy!
      >[/color]

      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.

      Comment

      • Jim Carlock

        #4
        Re: XP exec background process

        "Shailesh Humbad" <humbads@nowher e.invalid> posted:[color=blue]
        > BTW, Windows does not care about capitalization on the command line.[/color]

        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.


        Comment

        • Shailesh Humbad

          #5
          Re: XP exec background process

          Jim Carlock wrote:[color=blue]
          > "Shailesh Humbad" <humbads@nowher e.invalid> posted:[color=green]
          >> BTW, Windows does not care about capitalization on the command line.[/color]
          >
          > 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.
          >
          >[/color]

          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:



          Comment

          Working...