public static Process performCommand(String command) {
//command:命令
try {
return Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
例:1、重启机器
String commd="C:\\Windows\\System32\\shutdown -r -f -t 0";
Process pro=performCommand(commd);
2、管理某一应用进程
String command="taskkill /f /im DecodingOnWallService.exe";
Process pro=performCommand(command);
3、启动某一应用进程
String exePath="d\\decodeServer\\DecodingOnWallService.exe";
Process startPro=performCommand(exePath);
//command:命令
try {
return Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
例:1、重启机器
String commd="C:\\Windows\\System32\\shutdown -r -f -t 0";
Process pro=performCommand(commd);
2、管理某一应用进程
String command="taskkill /f /im DecodingOnWallService.exe";
Process pro=performCommand(command);
3、启动某一应用进程
String exePath="d\\decodeServer\\DecodingOnWallService.exe";
Process startPro=performCommand(exePath);