[英]How can I change this code so that the command prompt closes when it finishes executing?
Runtime.getRuntime().exec("cmd /c start rake.bat");
我希望它运行rake.bat然后在完成后关闭命令行。 我做了一次,但忘了我做了什么。 我正在使用Java。
您可能只是不需要start
命令:
Runtime.getRuntime().exec("cmd /c rake.bat");
将Runtime
对象存储在变量中以使用它,然后在完成后调用它的exit()
方法。
exit(int status) :
通过启动其关闭序列来终止当前运行的Java虚拟机。
不存储变量:
Runtime.getRuntime().exit(0);
要关闭命令行,请使用此...
Runtime.getRuntime().exec("cmd exit");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.