How to run multiple .BAT files within a .BAT file

run multiple batch files in sequence
run batch file one after another
how to run multiple exe files from batch one after another
batch file run multiple commands simultaneously
batch file call another batch file and return
calling batch file from another batch file in different directory
batch file run multiple commands sequentially
run all batch files in a folder

I'm trying to get my commit-build.bat to execute other .BAT files as part of our build process.

Content of commit-build.bat:


This seems simple enough, but commit-build.bat only executes the first item in the list (msbuild.bat).

I have run each of the files separately with no problems.


call msbuild.bat
call unit-tests.bat
call deploy.bat

When not using CALL, the current batch file stops and the called batch file starts executing. It's a peculiar behavior dating back to the early MS-DOS days.

How to run multiple batch files with one master batch file, 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\"  Asked 3 years, 7 months ago. Active 2 years, 10 months ago. Viewed 7k times. 2. I have made a batch script to run some .exe files and .bat files. The format of the script is as follows: a.exe b.exe c.bat d.bat e.bat f.exe g.exe. but the problem is when I run the script it is only executed till c.bat. d.bat is not executing.

All the other answers are correct: use call. For example:

 call "msbuild.bat"


In ancient DOS versions it was not possible to recursively execute batch files. Then the call command was introduced that called another cmd shell to execute the batch file and returned execution back to the calling cmd shell when finished.

Obviously in later versions no other cmd shell was necessary anymore.

In the early days many batch files depended on the fact that calling a batch file would not return to the calling batch file. Changing that behaviour without additional syntax would have broken many systems like batch menu systems (using batch files for menu structures).

As in many cases with Microsoft, backward compatibility therefore is the reason for this behaviour.


If your batch files have spaces in their names, use quotes around the name:

call "unit tests.bat"

By the way: if you do not have all the names of the batch files, you could also use for to do this (it does not guarantee the correct order of batch file calls; it follows the order of the file system):

FOR %x IN (*.bat) DO call "%x"

You can also react on errorlevels after a call. Use:

exit /B 1   # Or any other integer value in 0..255

to give back an errorlevel. 0 denotes correct execution. In the calling batch file you can react using

if errorlevel neq 0 <batch command>

Use if errorlevel 1 if you have an older Windows than NT4/2000/XP to catch all errorlevels 1 and greater.

To control the flow of a batch file, there is goto :-(

if errorlevel 2 goto label2
if errorlevel 1 goto label1

As others pointed out: have a look at build systems to replace batch files.

Batch files - CALL, The CALL statement was introduced in MS-DOS 3.3. It is used to call other batch files within a batch file, without aborting the execution of the  If you want to open many batch files at once you can use the call command. However, the call command closes the current bat file and goes to another. If you want to open many at once, you may want to try this: @echo off start cmd "call ex1.bat&ex2.bat&ex3.bat" And so on or repeat start cmd "call" for however many files.

If we want to open multiple command prompts then we could use

start cmd /k

/k: is compulsory which will execute.

Launching many command prompts can be done as below.

start cmd /k Call rc_hub.bat 4444

start cmd /k Call rc_grid1.bat 5555

start cmd /k Call rc_grid1.bat 6666

start cmd /k Call rc_grid1.bat 5570.

Running Batch Files with a Batch File, Running Batch Files with a Batch File start cmd /k call "C:\Users\H\Desktop\​Applications Duration: 7:00 Posted: Sep 2, 2017 If the master batch file is like this: call Batch1.bat call Batch2.bat call Batch3.bat then all of the sub-batch files start running at the same time and I get hundreds of executables trying to start up at the same time. How do I make the master batch file call the first batch file, wait for it to finish, then call the next, wait for it to finish, then call the next, etc?


call msbuild.bat
call unit-tests.bat
call deploy.bat

cmd - How to run multiple .BAT files within a .BAT file, bat to execute other .BAT files as part of our build process. Content of commit-​build.bat : "msbuild.bat" "unit-  I 've created the following batch file and run it whenever I open my laptop in the office to open relevant programs at a single click. Kept this file at Desktop and created a folder where I put all shortcuts for relevant programs. So, I run these shortcuts in the batch file as follows:

You are calling multiple batches in an effort to compile a program. I take for granted that if an error occurs: 1) The program within the batch will exit with an errorlevel; 2) You want to know about it.

for %%b in ("msbuild.bat" "unit-tests.bat" "deploy.bat") do call %%b|| exit /b 1

'||' tests for an errorlevel higher than 0. This way all batches are called in order but will stop at any error, leaving the screen as it is for you to see any error message.

Batch file, A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of When a batch file is run, the shell program (usually COMMAND. Batch files for other environments may have different extensions, e.g., .btm in 4DOS value of the errorlevel variable only upon an error, whereas from within a .cmd file,  On Windows 10, a batch file is a special kind of text file that typically has a .bat extension, which can include one or multiple commands that Command Prompt can understand and run in sequence to

CALL - Execute one batch file from within another, CALL allows batch files to call other batch files (batch file nesting). The calling batch file is suspended while the called (second) batch file runs. When the second  I want to run ONE batch file, that starts 4 other batch files. Problem: Only the first CMD file gets executed. I looked at a similar questions posted here: How to run multiple .BAT files within a .BAT file And here: How do I launch multiple batch files from one batch file with dependency?

Run multiple batch (.bat) files from a single batch file and hold the , Running multiple batch file (.bat) into one batch file. SET MSBuildPath=C:\​Program Files (x86)\MSBuild\14.0\bin\amd64\ SET RootPath= 

Batch Files Run from Within Other Folders May Fail, Although the batch file does not run from the root directory, the command will run if you enclose the command line within quotes. For example