>简要: Runtime runtime=Runtime.getRuntime();
定时关机:runtime.exec("shutdown -s -t 600");
取消定时关机:runtime.exec("shutdown -a");
- 具体流程code:
package com.mystudy.amuse;
import java.io.IOException;
public class Timingshutdown {
public static void main(String[] args) throws IOException {
Runtime runtime=Runtime.getRuntime();
// 仅限在Windows系统
//shutdown -s -t 600 中600代表多少秒后关机
runtime.exec("shutdown -s -t 600");
//取消自动关机
runtime.exec("shutdown -a");
}
}