如何cmd.exe从java启动? [英] how can cmd.exe be launched from java?
本文介绍了如何cmd.exe从java启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
in .net如果我想打开一个新的命令行窗口,我可以写。
in .net if I wanted to open a new command line window, I could just write.
System.Diagnostics.Process.Start("cmd.exe");
但是,以下代码不执行任何操作:
in java, however, the following code does nothing:
new java.lang.ProcessBuilder("cmd.exe").start();
java.lang.Runtime.getRuntime().exec("cmd.exe");
没有创建新窗口,并且任务管理器中不显示任何进程。
No new window is created and no Process appears in Task Manager.
现在如果我试图打开的应用程序是notepad.exe,然后java会打开它只是很好。
Now if the application I was trying to open was "notepad.exe", then java would open it just fine.
?
推荐答案
Runtime.getRuntime().exec(new String[]{"cmd.exe","/c","start"});
至了解更多开始,在命令提示符下键入 help start
。
To learn more on start, type help start
at command prompt.
这篇关于如何cmd.exe从java启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文