17

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?

finoutlook
  • 2,523
  • 5
  • 29
  • 43

2 Answers2

30

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.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • Thanks, just found this mentioned in http://stackoverflow.com/questions/324539/how-can-i-run-a-program-from-a-batch-file-without-having-the-console-open-after too. Any ideas about the dynamic loading in a batch file? – finoutlook Feb 06 '12 at 13:08
  • START command interprets 1st argument as window title if it is quoted, so you need to specify a title like`start "" "C:\Development\App\bin\Debug1\Application.exe"` – dbenham Dec 30 '16 at 16:06
8
@echo off
for %%F in ("Debug\Applications\*.exe") do (
  start "" "%%F"
  timeout 5
)
dbenham
  • 127,446
  • 28
  • 251
  • 390
  • Thanks this helped alot. I've given the accepted answer to the other user as it answered the first question I had, so best I can do is an upvote. – finoutlook Feb 06 '12 at 16:48