Search code examples
windows-xpbatch-filecmd

How do I run a bat file in the background from another bat file?


I have a "setup" script which I run in the morning which starts all the programs that I need. Now some of those need additional setup of the environment, so I need to wrap them in small BAT scripts.

How do I run such a script on Windows XP in the background?

CALL env-script.bat runs it synchronously, i.e. the setup script can continue only after the command in the env-script has terminated.

START/B env-script.bat runs another instance of CMD.exe in the same command prompt, leaving it in a really messy state (I see the output of the nested CMD.exe, keyboard is dead for a while, script is not executed).

START/B CMD env-script.bat yields the same result. None of the flags in CMD seem to match my bill.


Solution

  • Actually, the following works fine for me and creates new windows:

    test.cmd:

    @echo off
    start test2.cmd
    start test3.cmd
    echo Foo
    pause
    

    test2.cmd

    @echo off
    echo Test 2
    pause
    exit
    

    test3.cmd

    @echo off
    echo Test 3
    pause
    exit
    

    Combine that with parameters to start, such as /min, as Moshe pointed out if you don't want the new windows to spawn in front of you.