'Call multiple .bat from another .bat without waiting for one to finish

So, I want to make a script that will execute 2 .bat files and start some .exe files.

However, the .bat files are supposed to keep running.

I have something like this :

pushd tools\wamp64
start wampmanager.exe

pushd ..\..\server\login
call startLoginServer.bat

pushd ..\test
call startTestServer.bat

start "C:\DEV\P2\Test\client" P2.bin

The problem is that call startLoginServer.bat will not exit and therefore, I'm stucked here.

How can I run my 2 .bat files and let them keep running. (Ideally, I want them to run in 2 different command prompt windows)

Also, there is probably a better way to handle relative path than using pushd if you can correct me on this.

Thanks



Solution 1:[1]

You could use:

start "Wamp Manager" /B /D "%~dp0tools\wamp64" wampmanager.exe
start "Login Server" /B /D "%~dp0server\login" startLoginServer.bat
start "Test Server"  /B /D "%~dp0server\test"  startTestServer.bat
start "Text Client"  /B /D "%~dp0" "C:\DEV\P2\Test\client.exe" P2.bin

Run in a command prompt window start /? for help on this command explaining the options.

  1. "..." ... title for new console window which is optional, but must be often specified on program to start is or must be enclosed in double quotes. The START command in last command line in batch file code in question interprets C:\DEV\P2\Test\client as window title. It is also possible to use an empty window title, i.e. "" which is best if the started application is a Windows GUI application on which no console window is opened at all.

  2. /B ... run without opening a new window, i.e. in "background". This option can be omitted to see what the started applications and batch files output to console if the executables are not Windows GUI applications.

  3. /D "..." or also /D"..." defines the directory to set first as current directory before running the command specified next. %~dp0 references the directory of the batch file containing these commands. This path always ends with a backslash. Therefore no backslash must be added on concatenating the directory of the batch file with a file or folder name or path.

Run in a command prompt window call /? for help on %~dp0 explaining how arguments of a batch file can be referenced from within a batch file.

See also the answer on How to call a batch file that is one level up from the current directory? explaining in total four different methods to call or run a batch file from within a batch file.

Finally read also the Microsoft documentations about the Windows kernel library function CreateProcess and the structure STARTUPINFO used by cmd.exe on every execution of an executable without or with usage of its internal command start. The options of start become more clear on having full knowledge about the kernel function and the structure used on Windows to run a program.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1