Skip to main content

Program your PC to turn off automatically by asigning which time you want it to do that

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..







Comments

Popular posts from this blog

[Updated] Windows 8 / 8.1 product key with Activator 2016

Windows 8 / 8.1 Product key for activation 2015 Windows is doubtlessly one of the best operating systems out there. It has many awesome features and updates which make it unique and keeps the users attached to itself. Not only easy usable interface also some features which is very unique compared to other open source and Linux operating systems. Thus it is suitable for users such as windows 8.1 key, windows 8 keys, product key for windows 8, windows 8 product key, windows 8.1 CD key, window 8.1 product key. Windows 8 Product Key / Windows 8.1 Product Key windows 8-8.1 product keys There are many versions in the windows 8. It has trail preview versions such as windows 8 developer preview, windows 8 release preview, & finally the windows 8 RTM which is the retail pack of the windows. Not only the PC operating system but also the server OS which is required to run powerful servers also available with the windows release. Windows 8.1 and 8 Product Key List: Here we a

[Working] SpyHunter 4 Email and Password 2016 Free download

[Working] SpyHunter 4 Email and Password 2016 Free download SpyHunter 4 Email And Password 2016 Free Download Crack Hello friends, this post is the updated version and I have published this version and it is 100% true and all the given credentials are working emails and passwords with the Spyhunter registration key in this post. Through this post you can get the SpyHunter malware protection software Email  and password easily. SpyHunter 4 Email And Password 2016: Spyhunter 4 2016 version is a very good anti virus and a spyware. It is one of the most used anti-spyware application. It supports all kinds of the computer applications and it prevents the computer from the most dangerous viruses. It works with the advanced technology’s. It has the capacity to detect and remove all the spywares and other applications that install the unwanted applications and make problems to the computer system. It also prevents the system from Trojans and other spyware programs. Here I’m giving you

[100% Working] Kaspersky Internet Security 2016 Key Free Download

[100% Working] Kaspersky Internet Security 2016 Key Free Download Kaspersky Internet Security 2016 Serial Keys Kaspersky activation code: As we all use the Internet more and more, cyber criminals are finding new ways to get kaspersky 2016 key and attack suspecting users – to steal money, personal information & identities. If you use the Internet regularly – for shopping, banking & socializing – your PC needs much more than just antivirus protection. In 2013, AV-Comparatives – the independent testing lab – gave its ‘Product of the Year’ award to Kaspersky Internet Security 2016 Keys. If you are still using the old and outdated antivirus program then it’s time to use Kaspersky Internet Security 2016 free license keys activation code for 180 days. The product key will be unique and provided by the official antivirus company so that you don’t have to buy new one. Kaspersky Internet Security includes all of the features provided by Kaspersky Anti-Virus… plus a vast range of a