I want to run one batch file, that start the other batch files. I looked at a similar question posted here: How to run multiple .BAT files within a .BAT file
I followed the example (specifically the very last suggestion) and it worked...partially. It did launch the batch files that I needed to. However, in order for the applications to function properly, some of these batch files have to open, and then run their course for a few seconds, before the next the next batch file launches, otherwise they won't be registered. Specifically, the first batch file launches a web applications server (JBOSS 5.1), then the next batch file opens a pool manager, then the other two launch distribution servers. When I run my batch file that calls the others, they all launch nearly simultaneously, and they do not register each other. Can I even do this with a batch file? Or do I have to go into the code of the other batch files and make changes there? I want to avoid that at all costs.
Here is what I have so far:
start cmd /k CALL D:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\bin\run.bat
start cmd /k CALL batch1.bat
start cmd /k CALL batch2.bat
start cmd /k CALL batch3.bat
You can drop the start cmd /k
and just use CALL
.
CALL D:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\bin\run.bat
CALL batch1.bat
CALL batch2.bat
CALL batch3.bat
Answer:
Add the /wait
option to the start command.
WAIT Start application and wait for it to terminate.
Example:
start /wait cmd /k CALL D:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\bin\run.bat
start /wait cmd /k CALL batch1.bat
start /wait cmd /k CALL batch2.bat
start /wait cmd /k CALL batch3.bat
Otherwise just use a ping delay between the starts. (See user706837's Answer)
References:
Technet
, Rob
, SS64
, DosTips
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With