[VBS script] timed prompt and shuts down the computer

Source: Internet
Author: User

First, Natalia.bat

Double-click this file to run Natalia

The console will be minimized when opened, with the title powerassistant, black background light green text

Run Script Natalia.vbs

1@ECHOOFF 2  3 REMThe script minimizes the run.4 IF "%1"=="m" GOTOBEGIN5Mshta VBScript:CreateObject("Wscript.Shell"). Run ("%~fs0 M",6) (Window.close) &&EXIT 6 : BEGIN7  8 REMNote Finally, you must follow an interpreter to recognize half-width characters, or the script will run an error.9 REMsets the command-line header.Ten TITLE powerassistant One   A REMsets the command line color. - REMForeground color (0= black, 1 = blue, 2 = green, 3 = aqua, 4 = red, 5= violet, 6 = yellow, 7 = white, 8 = Gray, 9 = light blue). - REMbackground color (a=, b= light green, c= pale red, d= light purple, e= yellow, f= bright white). the COLOR 0A -   - REMCall the countdown script. -CSCRIPT Natalia.vbs//nologo +   -PAUSE

Second, Natalia.vbs

In the top "Define constants section", you can set the expected shutdown time

1 Option Explicit2  3 'Defining Constants4 ConstObjhour = at   'when 0-235 ConstObjminute = -   'Sub 0-596 ConstObjsecond =xx   'sec 0-597  8 'Check that the input is legal9 DimIsinputlegalTenIsinputlegal =True One IfObjhour <0 OrObjhour > at  Then AIsinputlegal =False - End If - IfObjminute <0 OrObjminute > -  Then theIsinputlegal =False - End If - IfObjsecond <0 OrObjsecond > -  Then -Isinputlegal =False + End If - IfIsinputlegal =False  Then +WScript.Echo"input illegal time interval: [0-23] Inter-partition: [0,59] Second interval: [0,59]" A Wscript.Quit at End If -   - 'Defining Variables - DimObjtime'Target Time - DimCurtime'Current Time - DimCurhour'Current Time in DimCurminute'Current points - DimCursecond'Current seconds to   +Objtime ="Target time:"& Objhour &"when"& Objminute &"points"& Objsecond &"seconds" -   the DimIstimeout *Istimeout =False $  Panax Notoginseng 'time to end the loop -  Do UntilIstimeout =True the       +Curhour =Hour(now) ACurminute =Minute(now) theCursecond =Second(now) +       -Curtime ="Current Time:"& Curhour &"when"& Curminute &"points"& Cursecond &"seconds" $WScript.Echo Objtime &" | "&Curtime $       -     If(Curhour = Objhour andCurminute = Objminute andCursecond = Objsecond)Or _ -(Hour(now) = Objhour and Minute(now) = Objminute and Second(now) = objsecond+1) Then theIstimeout =True -     End IfWuyi       theWscript.Sleep ( +) -       Wu Loop -   AboutWScript.CreateObject ("Wscript.Shell"). Run"shutdown-s-T",0 $ WScript.Echo VbCrlf -WScript.Echo"pack up and get ready for bed! I'll turn off your computer in 5 minutes." -WScript.Echo"You can cancel the shutdown schedule by entering the command shutdown-a the console" -WScript.Echo VbCrlf

Third, the Operation effect

[VBS script] timed prompt and shuts down the computer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.