title: Execute .bat file from java and wait till its finished
body: <p>I have gone through few questions raised on how to achieve this.
  I used <code>process.waitFor()</code> and <code>/wait</code> as mentioned <a href="https://stackoverflow.com/questions/6444812/executing-a-command-from-java-and-waiting-for-the-command-to-finish?rq=1">here</a>. The problem is by doing so it waits not just till the command is executed but until cmd prompt is closed (can be done by adding <code>exit</code> in the bat file). But I cannot modify bat file as its a Product file.</p>
  
  <pre><code>Runtime run = Runtime.getRuntime();
  
      try {
          String path = "C:/Folder/c.bat";
          String executeCmd= "cmd /c start /wait "+path;
          final Process process =run.exec(executeCmd);        
          process.waitFor();
           System.out.println("did I wait?");
      } catch (Exception e) {         
          e.printStackTrace();
      }
  </code></pre>
  
  <p>How to make it wait only till the command is executed.</p>