Program Your PC to Turn Off Automatically by Asigning Which Time You Want It to Do That

41K2357

Intro: Program Your PC to Turn Off Automatically by Asigning Which Time You Want It to Do That

hey, thats another instructabel taken from my daily life...

last time i had to download lots of software to my PC and i had to let it download overnight, i didnt want to keep my PC turned on all night long after finishing the downloads and at the same time i couldnt stay awake to wait for it to finish the downloads and turn it off! therefore i made a VBscript that allows the PC to turn Off automatically in an interactive way !, i assign the minutes the PC will be turned on before shutting down according to how much time the downloads will take, i give it some little extra time to turn off after the time required for download in case there may be any decrease in speed but at least i wont stay awake nor i will keep my PC turned all night long doing nothing! and the PC in this case will be interactive with the user as i added to it some voice and narration too!
therefore watch my instructabel!

and if you like plz put a comment!
thanks

STEP 1: Start by Writing the Script...


open notepad, and write the following script into notepad:

Dim x
Dim y

set oShell = createobject("wscript.shell")
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")

x = InputBox("Would you like to shutdown your PC after a preiod of time? answer: yes/no","AUTOMATIC SYSTEM SHUTDOWN! by SCRIPTmaster")

if x = "yes" then
y = InputBox("Enter time left for shutdown to occur automatically(time in minutes...):","AUTOMATIC SYSTEM SHUTDOWN!")
sapi.speak y + "minutes left for shutdown"
oShell.Run "shutdown.exe -s -t " & (y * 60) & " -f -c ""System is now set for automatic shutdown! do not wait for the downloads to finish, you can go to sleep! GOOD NIGHT! see u 2morow! >>>>to terminate this Automatic shutdown just rerun the script and type no"""

end if
if x = "no" then
sapi.speak "okay, as you wish good bye, script writen by Ayman Farhat the SCRIPTmaster"
oShell.run "shutdown.exe -a"
end if

STEP 2: Detailed Description of the Code in the Script...

Dim x and Dim y ///declare the variables x and y responsible for the answer and the time respectively.

set oShell = createobject("wscript.shell") /// calls the OS shell and creates the object wscript.shell

Set Sapi = Wscript.CreateObject("SAPI.SpVoice") ///calls the windows SAPI and creates the object SAPI.SpVoice which is responsible for the speech in this script as it narrates to the user...

x = InputBox("Would you like to shutdown your PC after a preiod of time? answer: yes/no","AUTOMATIC SYSTEM SHUTDOWN! " ///calls the input where the user says if he wants to shut down his PC

if x = "yes" then /// is a branching statement
y = InputBox("Enter time left for shutdown to occur automatically(time in minutes...):","AUTOMATIC SYSTEM SHUTDOWN!") // if the user chooses yes then he is promted by another input to asign the time left for shutdown
sapi.speak y + "minutes left for shutdown" ///the windows SAPI reads the minutes left

oShell.Run "shutdown.exe -s -t " & (y * 60) & " -f -c ""System is now set for automatic shutdown! do not wait for the downloads to finish, you can go to sleep! GOOD NIGHT! see u 2morow! >>>>to terminate this Automatic shutdown just rerun the script and type no""" ///this is the shutdown statement which calls the system shutdown executable to launch and shuts the PC according to the given time which is in this case the variable y!
end if //ends the first if statement which is in this case yes

if x = "no" then //.another is statement responsible for the no answer
sapi.speak "okay, as you wish good bye, script writen by Ayman Farhat the SCRIPTmaster" ///the SAPI speaks to the user and tells him good bye
oShell.run "shutdown.exe -a" / /the shutdown.exe is called in this case and is told not to perform the shutdown by adding -a !
end if // end of the if statement!

that was a breif yet detailed description, know go to the next step to see what to do...

STEP 3: Saving Your Script

after you have entered your script to notepad you have to save it,
click save, and in the place where you type the name of your file put the name of your file followed .vbs as shown in the figure...

STEP 4: Run Your Script...

double click on the VB program you just saved and see the magic!
you will be first prompted by an input askig you wether you want to shut down or not as show in the figure. if you do not choose to shut down by typing no the program will end automatically...
if you choose to shutdown by typing yes you will be prompted by another input asking the number of minutes you want your PC to stay turned on as shown in the figure below.
and then the shutdown countdown will start
if you want to end that shutdown for any reason just rerun the program while the shutdown is taking place and type no and it will terminate autonomously!

So that was a solution for a problem that a lot of PC users suffer from! hope you liked my instructable
if you do, please leave a comment i will be so pleased to hear from you.
GOOD LUCK and GOOD NIGHT!

56 Comments

I bow down before thee (I haven't tried it yet, though) but have been baffled for quite some time why the virus scan developers don't include a "do you want to shut down after scan is complete" thing. I mean DUH. You are my god now. Thanks!

mcafee has it

I am working on the website for the program that i told you about, i will finish it this week hopefully and the program will be available next week(the BETA version) and then i will be making release after release, each with bug fixes and new cool things! when everything is ready i will post the link here on the comments! ;)
thanks man! just wait a little and you will see the next version of this great program! i am almost done writing the program and i will make t available free for download in the coming weeks. The new one is much advanced! it has more options and has animations and its writen in java! once i upload the program to the net i will PM you! ;)

Is it possible to use this to make it go to sleep or hibernate?

Doesn't the input box only return a string, not a number?
Great for when I'm likely to fall asleep watching a vid!! Thank you. (Can the program be amended to run without manually starting and to do the shutting down at the same time each day?)
 I am glad i am just a little geek. because i don't understand anything of this.
 hi , if you can not understand this take this easy program you can download it from  here :
http://versus.comlu.com/articles.html

I meant more or less the script the program it self would probably be quite easy to use, but i don't believe i am able to use it whit vuze. And any way i don't have any use for it.
Thats some damn good script. You are a script master
create a shortcut on your desktop, go to his properties and in the "target" box type this %windir%\system32\shutdown.exe -s -f -t 00 where 00 is the time till shutdown, and in the "start in" box type" %windir%, so you dont have to type all that every time you want to schedule your pc for shutdown. you can also create a shortcut with the -r to stop the shutdown
some computers have so many locks that it doesn't work. Any advice???
Try running as administrator.
More Comments