zoukankan      html  css  js  c++  java
  • windows批处理定时关机

    2017-04-11

    windows bat文件可以简化很多cmd命令,为我们提供很多方便。今天介绍定时关机的批处理代码实现;

    我们知道windows下的定时关机可以通过shutdown命令实现,如果每次都要调出cmd窗口去输入命令可能会比较麻烦,这里我们可以直接通过批处理来实现。

    这里直接上代码吧:

    @echo off
    mode con lines=30 cols=60

    :ts
    cls
    color 2f
    echo.
    echo ------------------------------------------------------------------------------------------------
    echo ------------------------------------------------------------------------------------------------
    echo --------------------------输入1 进入定时关机------------------------------------------------
    echo -------------------------------输入2 取消定时-----------------------------------------------------
    echo -------------------------------------------------------------------------------------------------------

    set /p num=输入1或2:
    if %num%==1 goto ds
    if %num%==2 goto qx
    cls
    goto ts

    :ds

    cls
    color 2f
    set /p time=请输入时间(h):
    set /a time*= 3600
    shutdown -s -t %time%
    goto end

    :qx
    cls
    color 2f
    shutdown -a
    echo.
    echo 已取消定时
    goto end

    :end
    echo ---------------------设置成功-----------------------------------
    pause

    代码比较简单,还有很多值得改进的地方(比如说不支持小数的输入),大家看看就好。

  • 相关阅读:
    January 25th, 2018 Week 04th Thursday
    January 24th, 2018 Week 04th Wednesday
    January 23rd, 2018 Week 04th Tuesday
    January 22nd, 2018 Week 04th Monday
    January 21st, 2018 Week 3rd Sunday
    January 20th, 2018 Week 3rd Saturday
    January 19th, 2018 Week 3rd Friday
    January 18th, 2018 Week 03rd Thursday
    January 17th, 2018 Week 03rd Wednesday
    January 16th, 2018 Week 03rd Tuesday
  • 原文地址:https://www.cnblogs.com/jjj-fly/p/6695460.html
Copyright © 2011-2022 走看看