title: Waiting for batch process to finish before continuing with the rest of the codes in .java file
body: <p>I have this java file, where I need to invoke a batch file from,
  for this, I use the following line</p>
  
  <pre><code>Process proc = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+ "D:\\Builds\\automation\\INSTALLER\\SOURCE\\A.bat");
  </code></pre>
  
  <p>This runs fine, the bat file is invoked in command prompt.
  A.bat also has a few lines where 2 other bat files are called. You can consider them as B.bat &amp; C.bat</p>
  
  <p>After all these Batch files are run, there is a output.log file that is generated &amp; has information if the process was "successful" or there were "errors". So based on the words in the log, I will need to either print "SUCCESS" or "ERROR".</p>
  
  <p>Now, my problem is, I used </p>
  
  <pre><code>proc.waitFor();
  </code></pre>
  
  <p>so that the java file wait for the Process to finish before the remaining codes are run.
  This just does not happen. Even before B.bat is run, "SUCCESS" gets printed.</p>
  
  <p>Is there a way I could edit the batch file according to my needs or edit the java file to wait till the process completes?</p>