Run a batch file from Java program and get the status of execution
<p>I need to run a Batch file from my Java Program and know if that was completed or not.</p>

<pre><code>try{
    Process process = Runtime.getRuntime().exec( command );

    if( null!=process  &amp;&amp; process.waitFor() == 0 &amp;&amp;process.exitValue()== 0 )
     {
        LOGGER.debug("Command executed successfuly.["+command+"]");
        return 0;
    }
    else{
        LOGGER.debug( "Error while getting the modified log" );
        return 1;
    }
}
catch( IOException e ){
// TODO Auto-generated catch block
e.printStackTrace();
}
catch( InterruptedException e ){
// TODO Auto-generated catch block
e.printStackTrace();
}
</code></pre>

<p>My command is something similar to this <code>cmd /c C:/Test/test.bat</code>
This <code>test.bat</code> file takes some 10-15 minutes to complete. Immediately after this is executed, <code>process.exitValue()</code> returns <code>0</code>. But I need to know if this was executed completely or not. In my <code>test.bat</code> file, I'm calling another exe file which performs some operations. That exe file writes some error information to the console.I need to get that information.</p>

<p>Is it possible to know this from Java code? Or Can someone please let me know the best way to check this?
I thought of some approaches like writing the status(after successful completion) to a text file (from the batch program) and then check this from Java code. But I don't think that is the correct way to do this.</p>
