Monday, April 11, 2011

close a particular command prompt

hi, I have opened a commnad prompt using java program and another command prompt manually. Now my requirement is that i need to close the command prompt that i have opened by java program using the program.

I tried to close this by giving rt.exec("taskkill /IM cmd.exe");

But the problem is that the command prompt that i have opened manually is aslo closed which i dont want.

Help needed. Thanks in advance

From stackoverflow
  • if you're using Runtime.getRuntime().exec(), it returns a Process object. You should hold on to that and call Process.destroy() when you're done.

0 comments:

Post a Comment