VBS script _vbs that can be automatically shutdown at timed intervals

Source: Internet
Author: User
Copy Code code as follows:

Dim Mytime,myout1,myout2
Mytime=null
Mytime=inputbox ("Please enter timed time (format 20:10:05)" &vblf& "if you want to count down, please enter the countdown time" &vblf& "(unit/minute)" &vblf& "input ' xxx ' can be shut down immediately ' &vblf& ' exit point ' Cancel ', ' Timer shutdown ', ' 1 '
Set wshshell=wscript.createobject ("Wscript.Shell")
If IsNumeric (mytime) =false Then
If IsDate (mytime) =true Then
Wshshell.run "at" &mytime& "shutdown-s" ' Timed Shutdown in task List
Myout1=msgbox ("Timed success!") The computer will be shut down in "&mytime&"! Give up the shutdown please click ' Cancel '! ", vbOKCancel," timed shutdown ")
If Myout1=vbcancel Then
Wshshell.run "at/delete/y"
MsgBox "Shutdown canceled!" ", 64," timed shutdown "
End If
Else
If mytime= "xxx" Then
Wshshell.run "Shutdown-s-T 0"
End If
MsgBox "Input Error!" Please re-enter! ", 64," timed shutdown "
End If
Else
If mytime>600 Or mytime<=0 Then
MsgBox "Input Error!" The countdown can not be more than 10 hours (600 minutes)! ", 64," timed shutdown "
Wscript.Quit
End If
Wshshell.run "Shutdown-s-T" &mytime*60
Myout2=msgbox ("Set success!") The computer will be shut down after "&mytime&" Minutes! Give up the shutdown please click ' Cancel '! ", vbOKCancel," timed shutdown ")
If Myout2=vbcancel Then
Wshshell.run "Shutdown-a"
MsgBox "Shutdown canceled!" ", 64," timed shutdown "
End If
End If

Copy Code code as follows:

Set Diaolei=createobject ("Wscript.Shell")
Dim Shijian,guanji,hua
Shijian=time
Hua=inputbox ("Please enter what unit you want to shut down 1 for the minute 2 for the Hour 3 for the day")
If Hua=1 Then
Guanji=inputbox ("Please enter you want a few minutes after shutdown")
If DateDiff ("M", Shijian,time) >=guanji Then
Diaolei.run "Rundll32.exe user.exe,exitwindows"
Diaolei.run "Shutdown-s-T 0"
ElseIf hua=2 Then
Guanji=inputbox ("Please enter you want to shut down after a few hours")
If DateDiff ("H", Shijian,time) >=guanji Then
Diaolei.run "Rundll32.exe user.exe,exitwindows"
Diaolei.run "Shutdown-s-T 0"
ElseIf Hua=3 Then
Guanji=inputbox ("Please enter you need a few days after shutdown")
If DateDiff ("D", Shijian,time) >=guanji Then
Diaolei.run "Rundll32.exe user.exe,exitwindows"
Diaolei.run "Shutdown-s-T 0"
endif

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.