Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Executing multiple batch files in sequence

843841Apr 20 2004 — edited Apr 20 2004
I 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2004
Added on Apr 20 2004
1 comment
1,260 views