我尝试过以下代码,但没有任何反应。
List cmdAndArgs = Arrays.asList({"cmd", "/c", "simple.bat"});
String dir ="E:\\SK\\EXTRA KNOWLEDGE\\JAVA\\RUN OTHER APP";
ProcessBuilder pb = new ProcessBuilder(cmdAndArgs);
pb.directory(new File(dir));
Process p = pb.start();
和
Process process = Runtime.getRuntime().exec("notepad.exe");
答案 0 :(得分:0)
尝试:
Runtime.getRuntime().exec("cmd /c start YourBatch.bat");
答案 1 :(得分:0)
使用此:
Runtime.getRuntime().exec("cmd.exe", "/c", "./users/batch.bat");
答案 2 :(得分:0)
试试这个:
Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "simple.bat"});