This is a .vbs shutdown script that I made as a prank. The reason why it is so cool, is because instead of just shutting down the computer right away, the computer speaks to you, warning you that the computer will shutdown in 10 seconds, then it shows a little animation counting down the last 5 seconds before it shutdown the computer.
I also like compiling it to a .exe using a converter, but you don't have to do this. View my vbs Screen Lock, if you would like to know how to do this. There are also some links for vbs editors as well in that instructable.
But Unlike my screen lock, this program is a lot shorter, so I will try to explain it the best I can.
NOTE: If you do not already know vbs, I recommend checking out this Instructable so that you have a basic understanding of some of the functions used is this script.
Step 1: My Script...
Here is the script..
You will have to delete one of the "s" at the end so that it ends in "Shutdown.vbs" or what ever you want as long as it ends in .vbs.
Step 2: My Script (explanation)...
So know I will explain the code...
The first line does not really do much, it just helped me when I was creating the script. Here are the next three lines:
Dim objWshShl : Set objWshShl = WScript.CreateObject("wscript.shell") Dim objVoice : Set objVoice = WScript.CreateObject("sapi.spvoice")
The first line of code declares the variable that we will be using to control are For...Next Loop. The next two lines of code declares and sets 2 variables. objWshShl is used for the message box and run functions. objVoice is used to make the computer "talk".
Here are another three lines:
These lines are just calling the three functions that are in our script.
Here is the first function in are script.
objVoice.Speak "This computer will now shutdown in 10 seconds." WScript.Sleep 5000 End Function
We don't really need functions in our script, but it just helps keep things organized.
So all this does is speak the sentence in between the quotes and then pauses for 5 seconds before continuing to the next function.
This next part may seem kinda tricky but it is actually pretty easy to understand:
For IntCounter = 5 To 1 Step -1 objWshShl.Popup "Computer will shutdown in " _ & IntCounter & " seconds",1,"Computer Shutdown", 0+48 Next End Function
So first it creates a function called TimedMessageBox.
Then the next 4 lines are a For...Next Loop. So this loop will loop five times going down by one each time.
objWshShl.Popup "Computer will shutdown in " _
& IntCounter & " seconds",1,"Computer Shutdown", 0+48
This code is actually only one line of code, it is just separated into another line using the "_" character to make it easier to read. What this code does is it creates a popup message that last for 1 second display the amount of seconds left till shutdown using the IntCounter variable.
Once this loop loops five times, it continues on with the script.
Here is the next function:
objWshShl.Run "Shutdown /s /f /t 0",0 End Function
All this does is shutdown the computer using a run command. Here are the switches used: /s /f /t. The /s means to shutdown, the /f means to close all applications without warning, the /t is the time in seconds before shutdown. You will notice after that command there is a comma zero ",0". This just makes it so that no cmd widow flashes when the shutdown command is executed.
Step 3: Hope This Was Helpfull
Hope this Instructable was helpful if you need any more help or have any questions please pm me or leave a comment.