| Author |
How to close the command prompt open by Runtime.exec
|
Rajesh kt
Greenhorn
Joined: Oct 29, 2009
Posts: 2
|
|
Hi All,
I have a cmd file as shown below.
set ANT_HOME=%ANT_HOME%
%ANT_HOME%/bin/ant build.xml
I have written a java code to
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("cmd /c start/wait localbuild.cmd");
It works fine... opens a command prompt and runs the localbuild.cmd file .
Now i need to close this command prompt once it finished executing the cmd file.
How can i achive this...
Rajesh
|
 |
Siva Masilamani
Ranch Hand
Joined: Sep 19, 2008
Posts: 377
|
|
|
creaate a command array and put exit as the last element.
|
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
|
 |
Rajesh kt
Greenhorn
Joined: Oct 29, 2009
Posts: 2
|
|
|
thanks for the reply, but the command prompt get closed without executing the .cmd file
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Rajesh, please read your private messages.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Siva Masilamani
Ranch Hand
Joined: Sep 19, 2008
Posts: 377
|
|
What you want to do?
How do you know whether the cnmd file executes or not?
Does it execute before you add exit int he array?
|
 |
Leandro Coutinho
Ranch Hand
Joined: Mar 04, 2009
Posts: 415
|
|
|
put "exit" in the last line of your localbuild.cmd. Without quotes, of course.
|
 |
 |
|
|
subject: How to close the command prompt open by Runtime.exec
|
|
|