Executing multiple batch files in sequence
843841Apr 20 2004 — edited Apr 20 2004I need to execute multiple batch files in sequence. I cannot combine them into one batch file. The output files created by the first batch file have to be used by the second and third batch files.
The problem is that all the three batch files start executing at the same time. How can i make it wait until the first batch file execution is over and then start the next batch file ?
How can i determine the end of the execution of all the commands in a batch file.
I tried using the process.waitFor method and process.exitValue. But the values are always zero even before all the commands in the first batch file is executed.
This is the code i'm using:
rt1 = Runtime.getRuntime();
pr1= rt1.exec("cmd.exe /c start "+path+"/bat1.bat");
t= pr1.waitFor();
t =pr1.exitValue();
out.println("The value of t is"+t);
pr1= rt1.exec("cmd.exe /c start "+path+"/bat2.bat");
t= pr1.waitFor();
t =pr1.exitValue();
pr1= rt1.exec("cmd.exe /c start "+path+"/bat3.bat");
t= pr1.waitFor();
t =pr1.exitValue();
Please give your suggestions.
Thank You
Bindu