[英]java.io.IOException: Cannot run program “tskill”: CreateProcess error=2, The system cannot find the file specified
I'm trying to run a Java program that runs the tskill Windows command, but im getting the exception listed in the title. 我正在尝试运行一个运行tskill Windows命令的Java程序,但是我收到标题中列出的异常。 tskill is on the path when I run it from the command prompt. 在命令提示符下运行tskill时,它位于路径上。 I'm running this program as a Java Application in Eclipse. 我正在以Eclipse中的Java应用程序形式运行该程序。 I added c:\\windows\\system32 to the Path in eclipse, but the java program still can't find it. 我在Eclipse的Path中添加了c:\\ windows \\ system32,但是java程序仍然找不到它。 How do I fix this? 我该如何解决? How can I determine what path is set to in the java program? 如何确定Java程序中设置的路径?
try {
RunProcess.doExecuteCommand("tskill winword /A");
Thread.sleep(1000);
} catch (Throwable t) {
throw new GenerationException(t);
}
}
Try this 尝试这个
try {
Runtime rt = Runtime.getRuntime();
rt.exec("tskill winword /A");
} catch (Throwable t) {
t.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.