public static void main(String[] args) {
String batName = "C:/Users/fl/Desktop/test.bat";
Runtime rt = Runtime.getRuntime();
Process ps = null;
try {
ps = rt.exec("cmd.exe /C start /b " + batName);
ps.waitFor();
} catch (IOException e1) {
e1.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
int i = ps.exitValue();
if (i == 0) {
System.out.println("执行完成.") ;
} else {
System.out.println("执行失败.") ;
}
}
String batName = "C:/Users/fl/Desktop/test.bat";
Runtime rt = Runtime.getRuntime();
Process ps = null;
try {
ps = rt.exec("cmd.exe /C start /b " + batName);
ps.waitFor();
} catch (IOException e1) {
e1.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
int i = ps.exitValue();
if (i == 0) {
System.out.println("执行完成.") ;
} else {
System.out.println("执行失败.") ;
}
}