|
|
Re: Problem during executing Command Prompt through java
|
Posted: Jun 9, 2008 5:10 AM
|
|
> Just looked at the Runtime API, would addShutdownHook() > not work? You make the Shutdown hook Thread perform ^C. > > >
> Process child = Runtime.getRuntime().exec("yourCommand");
> Thread shutDownThread = new Thread() {
> public void run() {
> OutputStream ctrlC = child.getOutputStream();
> out.write("^C".getBytes());
> out.close();
> }
> });
>
> > Keep in mind this is just a suggestion i.e. this is the > route I'd pursue. Have never tried it - so I'm not sure > it would work.
My apologies, actually in the Shutdown thread, after executing your Ctrl+C command maybe you should input your second CMD to take in - that would make more sense.
You shutdown is called at the end of your process, then the next process is executed.
out.close();
// You then do within shutDownThread
child = Runtime.getRuntime().exec("anotherCommand");
|
|