Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start multiple console apps from a batch file

I'm trying to run some console application .exe files from a batch file in Windows.

However, when I run the following code it only starts the first of the apps:

"C:\Development\App\bin\Debug1\Application.exe"
timeout 5
"C:\Development\App\bin\Debug2\Application.exe"
timeout 5
"C:\Development\App\bin\Debug3\Application.exe"
timeout 5
"C:\Development\App\bin\Debug4\Application.exe"
timeout 5
"C:\Development\App\bin\Debug5\Application.exe"
timeout 5

(I've included the timeout to spread out the intial processing a bit)

Is there a way to get the script file to start the first application, then move on and start the others?

Ideally I would like the script file to start all applications in a subdirectory, so that if I had Debug\Applications\*.exe or similar it would start all applications of type .exe (and possibly waiting 5 seconds between each). Is this possible?

like image 672
finoutlook Avatar asked Feb 06 '12 13:02

finoutlook


2 Answers

You can start applications in the background by using start:

start "C:\Development\App\bin\Debug1\Application.exe"

Use start /? from a command window to get further details.

For example,

start dir

will open a new command window and show you a directory listing, leaving it open when finsished.

The:

start cmd /c "ping 127.0.0.1 && exit"

command will open a new window, run a four-cycle ping on localhost then exit.

In both cases, the current window will await the next command immediately.

like image 83
paxdiablo Avatar answered Sep 28 '22 01:09

paxdiablo


@echo off
for %%F in ("Debug\Applications\*.exe") do (
  start "" "%%F"
  timeout 5
)
like image 40
dbenham Avatar answered Sep 28 '22 01:09

dbenham