Dc Redwing
Dc Redwing

Reputation: 1791

Building a batch file to run exe files sequentially

I just start to learn how to build batch file. ( on the windows 7 environment)

I want to build the batch file which is able to run .exe files sequentially .

Run batch files sequentially

I was trying to apply above idea but I am not really sure how to apply it

For example, there are three file on the D:/

In "D:/" there are three .exe files.

  1. MyDriver.exe
  2. YouDriver.exe
  3. Mysoftware.exe

And I would like to build batch file which is running three exe files sequentially

Possible scenario is..

  1. Run batch file
  2. Run MyDriver.exe
  3. MyDriver file's install GUI pops up and then user start to install Mydriver
  4. Done with MyDriver.exe
  5. Run YouDriver.exe
  6. YouDirver file's install GUI pops up and then user start to install YouDriver
  7. Done with YouDriver.exe
  8. Run MySoftware.exe
  9. MySofrware install interface pops up and then user start to install MySoftware
  10. Done exit batch file.

I am not really sure if batch files can do it or not...

if it is impossible , is there any other options to build it ???

thanks

Upvotes: 10

Views: 80444

Answers (4)

javaboy
javaboy

Reputation: 57

start MyDriver.exe
start YouDriver.exe
start MySoftware.exe

If you want the batch file in a different dir you would have to do:

cd D:\
start MyDriver.exe
start YouDriver.exe
start MySoftware.exe

If you want a more flexible system:

echo Welcome to EXE starter!
set /p dir = DIR:
set /p exe = EXE1:
set /p exe1 = EXE2:
set /p exe 2 = EXE3:
cd DIR
start exe
start exe1
start exe2

There you go!

To do it squentially:

call YouDriver.exe
call MeDriver.exe
call Mysoftware.exe

call will halt the batch file until program has closed.

Upvotes: 4

foxidrive
foxidrive

Reputation: 41224

This will start each file and wait for it to complete and then launch the next one.

@echo off
start "" /w /b "d:\MyDriver.exe"
start "" /w /b "d:\YouDriver.exe"
start "" /w /b "d:\Mysoftware.exe"

Upvotes: 9

Joao
Joao

Reputation: 23

Try and put it in the same directory of the files you want to run. If you can't, use cd C:\Directory\Name to change it to the directory where the MyDriver.exe file is. Then just do MyDriver.exe- you don't need a call or start statement.

MyDriver.exe
YouDriver.exe
MySoftware.exe

use cd at the start if you neeed to.

Upvotes: 0

Aaron Miller
Aaron Miller

Reputation: 3780

You actually don't need to do anything special to make this happen; batch files are synchronous by default, so execution of the batch file will pause when an executable is launched, and resume when it exits. Something as simple as this should do:

@echo off
REM "@echo off" prevents each line from being printed before execution,
REM and is optional
REM "REM" introduces a comment line
D:\MyDriver.exe
D:\YouDriver.exe
D:\MySoftware.exe

Of course, if you're interested in checking the return values of the programs, to see whether they succeeded or failed to install (assuming the installer provides that information), then things become slightly more complicated; if that's what you need, mention it in a comment, and I'll expand my answer accordingly.

Upvotes: 10

Related Questions