在JAVA中,可以通过Runtime来实现对BAT或EXE的调用:
public
static
void main(String[] args) {
Runtime rt = Runtime.getRuntime();
try {
String file = "E:/eclipse/workspace/pack/test.bat";
rt.exec( "cmd.exe /c start " + file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Runtime rt = Runtime.getRuntime();
try {
String file = "E:/eclipse/workspace/pack/test.bat";
rt.exec( "cmd.exe /c start " + file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
test.bat文件内容如下:
@echo off
echo goodjob
pause & exit
echo goodjob
pause & exit
关于脚本的更多资料可以参考:
转载于:https://blog.51cto.com/kinkding/149739