簡體   English   中英

java.io.IOException:無法運行程序“ tskill”:CreateProcess錯誤= 2,系統找不到指定的文件

[英]java.io.IOException: Cannot run program “tskill”: CreateProcess error=2, The system cannot find the file specified

我正在嘗試運行一個運行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);
    }
}

嘗試這個

try {
    Runtime rt = Runtime.getRuntime();
    rt.exec("tskill winword /A");
} catch (Throwable t) {
    t.printStackTrace();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM