閺€鎯版 (0) +1 鐠э拷 (0) +1 闊拷 (0) +1
閺€鎯版閹存劕濮�閺屻儳婀呴弨鎯版>>

正在阅读:windows定时关机程序windows定时关机程序

2004-04-13 12:29 出处:CSDN 作者:gojava 责任编辑:sdq

  /**
  * Created by IntelliJ IDEA.
   * autor:cofbean
   * Date: 2004-3-10
   * Time: 13:41:48
   * qq:21439991
   */

  import java.io.IOException;

  public class CtrWDS {

      private static CtrWDS ourInstance = null;

      private CtrWDS() {
      }

      public static CtrWDS getInstance() {
          if (ourInstance == null) {
              ourInstance = new CtrWDS();
          }
          return ourInstance;
      }

    public void exec(String cmd) {
        try {
            Runtime.getRuntime().exec(cmd);
        }
        catch (IOException e) {
            System.out.println("执行失败");       
        }
    }


 public void shutdown() {
        exec("shutdown -S ");
    }

    public void restart() {
        exec("shutdown -R ");
    }

    public void logout() {
        exec("shutdown -L ");
    }

    public static void main(String[] str) {
        if (str.length == 0) {
            System.out.println("-----------------------\n" +
                    "关机  -s\n" +
                    "重起  -r\n" +
                    "注销  -l\n" +
                    "-----------------------\n");
        }
        else{
           try{
               Thread.currentThread().sleep(10000L);
            }
            catch(Exception e){
               CtrWDS.getInstance().exec(str[0]);
            }
         }

     }

 }

 

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
閹靛婧€鐠佸潡妫�閸ョ偛鍩屾い鍫曞劥