tags:

views:

240

answers:

3

Hi,

I have asked this question before. I am having the folowing requiremet.

  1. Run the batch file.
  2. Give some time to run the batch file. 3.Close the batch file

i have the following code that does not meet the requirement. Please tell me where i have made mistake

        Runtime rt = Runtime.getRuntime();
        Process pr = rt.exec(command);
       //pr.exitValue();
        //wait(10000);
        pr.waitFor();
        pr.destroy();

I have used the waitFor that doesnot work.how can i give delay for about 15 minutes after executing the batch file

Thanks

A: 

A suggestion: grab the output and error streams and see what they are printing out. You may see that there is an error happening with the batch file making it return sooner than you expect.

TofuBeer
String command = "cmd /C start pathtorun the batch file"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command);
A: 

I'm not sure what you want, but with

Thread.sleep(900000);

you can wait for 15 minutes.

Edwin
+1  A: 

If you do not have threads reading the stdIO from the batch process, the batch process can block. Even if you are not interested you still ned to read it and discard it. Then your wait for has a better change of working.

Clint