VBS implementation of timed shutdown, restart scripts and programs _vbs

Source: Internet
Author: User
Save the following code as a VBS file, such as: Shutdown.vbs, then double-click or point to right on file
The key selection opens with a command prompt, and if you set the reboot, the system will have a shutdown dialog.
Box.

Directly below the code program will appear shutdown dialog box, the final return comment off, normal use
, please remove the annotation character.

The following code is passed under Window 2000.

Copy Code code as follows:

' Timed shutdown or restart script, passed under Windows 2000
' Code by Haiwa 2005-11-7
Dim ActionId
ActionId = 1 ' 0 logoff, 1 shutdown, 2 reboot,
Actiontime = "2005-11-7 13:42:30" ' Shutdown or restart time

function ShutDown ()
Dim Objshell
Set Objshell = WScript.CreateObject ("Wscript.Shell")

Dim application
Set application = CreateObject ("Shell.application.1")
Application.shutdownwindows ()
Dim UPI
For UPI = 0 to 4
Wscript.Sleep (50)
Objshell.sendkeys ("{Up}")
Next
For UPI = 1 To ActionId
Wscript.Sleep (50)
Objshell.sendkeys ("{Down}")
Next
' When using, please remove the following annotation characters
' Objshell.sendkeys (' {ENTER} ')
End Function

While True
If DateDiff ("s", now, Actiontime) < 0 Then
ShutDown ()
End If
Wscript.Sleep (5*1000)
Wend

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.