关闭特定的命令提示符 [英] close a particular command prompt
问题描述
我已经使用java程序
和另一个命令提示符手动打开了一个commnad提示符。现在我的要求是我需要关闭我使用该程序通过java程序打开的命令提示符。
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.
我试图通过提供rt.exec(taskkill / IM cmd.exe)来关闭它;
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
推荐答案
这很简单 -
第1步
- 创建批处理文件(例如 closeCMD.bat )
Step 1
- Create a batch file (say closeCMD.bat)
第2步
- 在 closeCMD.bat
第3步
- 在java代码中调用上面的批处理文件,如下所示 -
Step 3
- call above batch file in your java code as below -
Runtime.getRuntime()。 exec(cmd / c start closeCMD.bat);
就是这样!!干杯!!
That's it !! Cheers!!
这篇关于关闭特定的命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!