close a particular command prompt

后端 未结 3 1959
礼貌的吻别
礼貌的吻别 2021-01-20 02:29

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 ja

相关标签:
3条回答
  • 2021-01-20 03:03

    you can try to program "exit" into the command prompt after you are done with your tasks in command prompt

    0 讨论(0)
  • 2021-01-20 03:19

    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 讨论(0)
  • 2021-01-20 03:19

    It's simple -

    Step 1 - Create a batch file (say closeCMD.bat)

    Step 2 - write exit in closeCMD.bat

    Step 3 - call above batch file in your java code as below -

    Runtime.getRuntime().exec("cmd /c start closeCMD.bat");

    That's it !! Cheers!!

    0 讨论(0)
提交回复
热议问题