转自 : http://blog.youkuaiyun.com/wyazyf/article/details/71602635?locationNum=1&fps=1
/*执行dos命令*/
public static void dosExe(String dosString) {
Runtime runtime=Runtime.getRuntime();
try{
runtime.exec(dosString);
}catch(Exception e){
System.out.println("Error!");
}
}
shutdown -s -t xx(xx是关机延时时间 /秒;xx可以是00,即时关机)at 10:00 shutdown -s ( 中间的时间是要关机的时间 后面是关机命令) 在 10点 关机 shutdown -a (取消关机,重启,注销等指令)
cmd /c start calc //打开计算器
cmd /c start是固定写法
dosExe("cmd /c start shutdown -a");