package test;import java.io.IOException;public class Test { public static void main(String[] args) {
System.out.println();
String s = "cmd /C " + System.getProperty("user.dir") + System.getProperty("file.separator")
+ "batTest.bat";
try {
Runtime.getRuntime().exec(s);
} catch (IOException e) {
e.printStackTrace();
}
}}
执行上述main方法,程序正常结束,但是批处理文件没有执行,双击这个批处理文件是可以执行的。
不知道是什么原因。
System.out.println();
String s = "cmd /C " + System.getProperty("user.dir") + System.getProperty("file.separator")
+ "batTest.bat";
try {
Runtime.getRuntime().exec(s);
} catch (IOException e) {
e.printStackTrace();
}
}}
执行上述main方法,程序正常结束,但是批处理文件没有执行,双击这个批处理文件是可以执行的。
不知道是什么原因。
package test;import java.io.IOException;public class Test { public static void main(String[] args) {
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec("cmd.exe /c"+"start /min d:\\a.bat");
} catch (IOException e) {
e.printStackTrace();
}
}}