〇、下载地址
115网盘:
Natalia 定时关机.rar
115网盘礼包码:5lbcx601n3hv
http://115.com/lb/5lbcx601n3hv
或百度网盘:
http://pan.baidu.com/s/1kTKaneJ
一、Natalia.bat
双击这个文件可以运行Natalia
控制台在打开后会变成最小化,标题为PowerAssistant,黑色背景淡绿色文字
运行脚本Natalia.vbs
@ECHO OFF REM 脚本最小化运行.IF "%1" == "m" GOTO BEGIN MSHTA VBScript:CreateObject("WSCript.Shell").Run("%~fs0 m",6)(Window.Close)&&EXIT :BEGINREM 注释最后一定要跟一个解释器可识别半角字符,否则脚本会运行错误.REM 设置命令行标题.TITLE PowerAssistantREM 设置命令行颜色.REM 前景色(0=黑,1=蓝,2=绿,3=浅绿,4=红,5=紫,6=黄,7=白,8=灰,9=淡蓝).REM 背景色(A=淡绿,B=淡浅绿,C=淡红,D=淡紫,E=淡黄,F=亮白).COLOR 0AREM 调用倒计时脚本.CSCRIPT Natalia.vbs //NOLOGOPAUSE
二、Natalia.vbs
在最上面的“定义常量部分”,可以设置预计关机的时间
Option Explicit'定义常量Const ObjHour = 23 '时 0-23Const ObjMinute = 30 '分 0-59Const ObjSecond = 00 '秒 0-59'检查输入是否合法Dim IsInputLegalIsInputLegal = TrueIf ObjHour < 0 Or ObjHour > 23 Then IsInputLegal = FalseEnd IfIf ObjMinute < 0 Or ObjMinute > 59 Then IsInputLegal = FalseEnd IfIf ObjSecond < 0 Or ObjSecond > 59 Then IsInputLegal = FalseEnd IfIf IsInputLegal = False Then WScript.Echo "输入非法 时区间:[0-23] 分区间:[0,59] 秒区间:[0,59]" WScript.QuitEnd If'定义变量Dim ObjTime '目标时间Dim CurTime '当前时间Dim CurHour '当前时Dim CurMinute '当前分Dim CurSecond '当前秒ObjTime = "目标时间:" & ObjHour & "时 " & ObjMinute & "分 " & ObjSecond & "秒"Dim IsTimeOutIsTimeOut = False'时间到则终止循环Do Until IsTimeOut = True CurHour = Hour(Now) CurMinute = Minute(Now) CurSecond = Second(Now) CurTime = "当前时间:" & CurHour & "时 " & CurMinute & "分 " & CurSecond & "秒" WScript.Echo ObjTime & " | " & CurTime If (CurHour = objHour And CurMinute = objMinute And CurSecond = objSecond) Or _ (Hour(Now) = objHour And Minute(Now) = objMinute And Second(Now) = objSecond+1) Then IsTimeOut = True End If WScript.Sleep(1000) LoopWScript.CreateObject("wscript.shell").Run "shutdown -s -t 300", 0WScript.Echo vbCrlfWScript.Echo "收拾收拾准备睡觉啦!5分钟后我会把你的电脑关掉哦~~~"WScript.Echo "在控制台输入命令 shutdown -a 可以取消关机计划"WScript.Echo vbCrlf
三、运行效果
END