0

我正在尝试运行一个运行 tskill Windows 命令的 Java 程序,但我得到了标题中列出的异常。当我从命令提示符运行 tskill 时,它就在路径上。我在 Eclipse 中将这个程序作为 Java 应用程序运行。我在eclipse的Path里加了c:\windows\system32,但是java程序还是找不到。我该如何解决?如何确定 java 程序中设置的路径?

    try {
        RunProcess.doExecuteCommand("tskill winword /A");
        Thread.sleep(1000);
    } catch (Throwable t) {
        throw new GenerationException(t);
    }
}
4

1 回答 1

1

尝试这个

try {
    Runtime rt = Runtime.getRuntime();
    rt.exec("tskill winword /A");
} catch (Throwable t) {
    t.printStackTrace();
}
于 2016-03-30T18:01:13.040 回答