Windows – How to run multiple batch files with one master batch file

batch filecommand linewindowswindows 8.1

I have three bat files I would like to run, in three different directories:

directory/bat1/bat1.bat

directory/bat2/bat2.bat

directory/bat3/bat3.bat

I would like to use one master .bat to start all of the other bats in their directories. I can't use call because I get errors because there are dependencies for each different bat in the directory. I tried using start but that doesn't work either, it just bring up a command prompt withing the folder.

I know this sounds a little confusing but all I want to do is use one single .bat file to run multiple .bat files independent from each other in their own directories.

Best Answer

If you use start, the other bat-files will create new process for each bat, and run them all at the same time.

cd "\directory\bat1\"
start bat1.bat
cd "\directory\bat2\"
start bat2.bat
cd "\directory\bat3\"
start bat3.bat

But if you want to run the next one after the last one is finished, you can use call

cd "\directory\bat1\"
call bat1.bat
cd "\directory\bat2\"
call bat2.bat
cd "\directory\bat3\"
call bat3.bat

don't forget the first \ at the beginning of the cd , otherwise it will try to change the directory into a subdirectory of the current working directory.

Related Question