I have to run a bat file in a loop in my java code. it means when a process finish for a file another process start after that. I ma using Thread.sleep in my project after calling process bat file. but the problem is I don’t know how a bat file does it take, for some file it takes 1 hour for some of them takes 10 minutes. how can i understand when a process will be finished ?
Share
If you run it by creating a
ProcesswithRuntime.getRuntime().exec(), you can call thewaitFor()method on theProcessto wait for it to exit.Using
Process.exitValue()you can even read error levels that the .bat files might return.