[ACCEPTED]-Executing a Command from Java and Waiting for the Command to Finish-execute
Accepted answer
I manged to find the answer elsewhere. To 2 keep the initial process open until the 1 batch file finished all you need is "/wait"
Process p = Runtime.getRuntime().exec("cmd /C start /wait filepath.bat");
int exitVal = p.waitFor();
calling "cmd /c start" causes cmd to fire 2 off another instance and exit immediately. Try 1 taking out the "start" command.
The answer given is correct. I added that 2 the window opened by the code needs to be 1 closed manually.
Process p = Runtime.getRuntime().exec("cmd /C start /wait filepath.bat");
int exitVal = p.waitFor();
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.