修改了前次程序的错误。
修改了如下内容。
::close command prompt
@echo off
::Set the default times
set Default_hour=17
set Default_minute=16
set Default_second=30
::Cycling.
:CopeHour
cls
::prompt the time of closing computer
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~Computer closed at 17:16~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~电脑将于下午五点十六分关闭~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::separate the time,get the hour, minute, second
for /f "tokens=1,2,3* delims=:" %%i in ("%time%") do (
::echo %%i %%j %%k
set C_hour=%%i
set C_minute=%%j
set C_MX_second=%%k)
::separate the MX second,get the second,mirsecond
for /f "tokens=1,2* delims=. " %%m in ("%C_MX_second%") do (
::echo %%m
set C_second=%%m)
echo ~~ 当前时间: %Date% %C_hour%:%C_minute% ~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~
echo ~请不要关闭当前窗口~
echo ~~~~~~~~~~~~~~~~~~~~
echo Coping...
set /a C_minute=%C_minute%+1
:CopeMinute
for /f "tokens=1,2,3* delims=:" %%x in ("%time%") do (
::echo %%x %%y %%z
set CC_minute=%%y
set CC_MX_second=%%z)
::separate the MX second,get the second,mirsecond
for /f "tokens=1,2* delims=. " %%o in ("%CC_MX_second%") do (
::echo %%o %%p
set CC_second=%%o
set CC_mirosecond=%%p)
if %CC_minute% GEQ %C_minute% (
goto ShutComputer) else (
::echo %C_hour%:%C_minute% %CC_second%.%CC_mirosecond%
goto CopeMinute)
::check times for shutdown the computer
:ShutComputer
if %C_hour% lss %Default_hour% (
::echo %C_hour% 1
::pause
goto CopeHour)
::原程序没有考虑到在已经过了规定时间(小时)时执行该脚本
::若程序被执行,这将导致在往后的每个小时规定时间里,关机一次(如果电脑正在运行)
if %C_hour% GTR %Default_hour% (
echo 当前时间:%time%
echo 默认关机时间:%Default_hour%:%Default_minute%
echo 已经过了。
pause
exit )
if %C_hour% EQU %Default_hour% (
if %C_minute% lss %Default_minute% (
::echo %C_hour%:%C_minute% 3
::pause
goto CopeHour)
if %C_minute% EQU %Default_minute% (
::echo %C_hour%:%C_minute% 4
start shutdown.exe -s -t 20
exit
goto CopeHour)
else (
::原程序没有考虑到在已经过了规定时间(分钟)时执行该脚本
::若程序被执行,这将导致在往后的规定的这个小时里,每一分钟,关机一次(如果电脑正在运行)
echo 当前时间:%time%
echo 默认关机时间:%Default_hour%:%Default_minute%
echo 已经过了。
pause
exit )
)
start shutdown.exe -a
exit
::pause
cls
goto CopeHour