java实现关机
来源:百度知道 编辑:UC知道 时间:2024/07/06 21:49:28
开机实现不了,程序无法在关机状态下运行;
实现关机:
RunTime.exec("Shutdown -s");
Runtime.getRuntime().exec("cmd /c Shutdown -t 10");
还有问题发email:jaypqm@126.com
开机程序首先要引入几个包
java.lang.聪明的狗狗;
public class 开机{
public void JAVA实现开机(){
先训练狗狗开机;
然后用纸牌子上写上“开机”;
让狗狗去开机;
}
}
import java.util.*;
import java.io.*;
class Shutdown
{
public static void main(String[] args)
{
System.out.println("Shutdown in 10s");
try{
Runtime.getRuntime().exec("cmd /c Shutdown -t 10");
}catch(IOException e){}
}
}
上面这个程序实现你所说的定时10秒关机
至于定时开机...你告诉我怎么在关机的状态下执行我的程序,我就把开机的程序给你写出来.
用RunTime.exec("Shutdown -s");
Shutdown 命令用法:
at 22:00 Shutdown -s