3

I have three .exe files inside a folder and I want to run them serially one after another through a batch file. That means, 2nd .exe file will execute after the operation of 1st .exe file. I have written a file but when I run it, the are not executing serially. My batch file is:

Start ""  ".\a.exe"
Start ""  ".\b.exe"
Start ""  ".\c.exe"

How will I execute these files one after another?

user3114849
  • 101
  • 1
  • 7

1 Answers1

4

Don't use start if you need to wait until the execution of the exe to execute the next one. start will create a new process and return to the next statement without waiting.

Just use the exe as it is without the start.

So your batch file should be like.

.\a.exe
.\b.exe
.\c.exe
seenukarthi
  • 8,241
  • 10
  • 47
  • 68
  • 2
    It will only wait if the EXE is marked as a Console app... if it's marked as a GUI app it won't wait unless you do `start /wait guiapp.exe`. – TripeHound Oct 19 '16 at 13:06
  • Will I write in this way? Start " " ".\a.exe" " " ".\b.exe" " " ".\c.exe" @Karthikeyan Vaithilingam – user3114849 Oct 19 '16 at 13:12
  • @user3114849 Updated my answer. – seenukarthi Oct 19 '16 at 13:16
  • @TripeHound: that's only true on the command line. The batch interpreter always waits regardless of whether it is a GUI or a console executable. – Harry Johnston Oct 19 '16 at 23:17
  • @HarryJohnston A quick test with `notepad` shows you are right, but I could have sworn I've seen the launch-and-forget behaviour in the past even from batch files, hence the need for `start /wait`. Unless it was all a dream... – TripeHound Oct 20 '16 at 08:19
  • @TripeHound: well, some applications launch child processes (or pass a command to an existing process) and then exit. But `start /wait` won't help in that case. – Harry Johnston Oct 20 '16 at 20:16
  • `start/w .\a.exe`
    `start/w .\b.exe`
    `start/w .\c.exe`
    – bim Aug 05 '19 at 14:47