Sometimes, We need to execute multiple batch files in a dos command line or batch programming.
There are multiple ways to execute .bat files
Let’s have the following batch files
To run all these batch files at once.
you can create a single batch file run.bat file
one.bat two.bat three.bat
on Running run.bat on command, It runs the first file(one.bat) and did not run the remaining batch files(two.bat,three.bat). In this approach, the only first line is executed and stops its execution.
So, DOS has introduced a
It runs batch file once completed, returned to calling line, like this executes until finished.
call command to execute multiple files.
Here is the code used to run multiple files. The files execute in sequential order with the order defined in the run.bat file.
call one.bat call two.bat call three.bat
on running the run.bat file,
It calls one.bat,two.bat and three.bat files in sequential order.
How to execute multiple files in multiple command prompts.?
It is an example of running multiple files in multiple command prompts. It is opposite to single command prompt to run multiple files in sequential order.
start cmd /k Call one.bat start cmd /k Call two.bat start cmd /k Call three.bat
start command opens new command prompt window.
-k option tells that must open a new window
Running run.bat do the following things
- It opens three command prompts, each calling batch files
- execution will not wait for the previous window context
- It is the parallel execution of multiple files in multiple commands that prompts context.
- No sequential order, If there is any dependency on each other batch files, and not recommended.
- It would be good to run multiple bat files independently