Windows scripting: How to Write Your Own Turn off Script
Have you ever been in a situation that you would like to turn off your computer in about an hour, and you will not be at home at the time? You could have been in such situation if, for example, you left your disc to defragment or the download of the certain Internet file were not over yet, and in the meantime, you left for a cup of coffee. That is just one of the examples, but there certainly are many occasions when you wish to turn your computer off in a precise time. Naturally, there are many applications for the occasion, made by various manufacturers, and they are free. In case you do not feel like looking for them everywhere in the Internet, you can write your own script for the computer turn off very quickly and accurately as well.
You can make such a script or a “small program” in two ways.
The first method is actually to not write a script at all. We only write the command in the command prompt, i.e. Run. So, all we have to do is to click the Run under Start menu and enter shutdown –s –t. After “-t” enter the wanted time of the turn off in seconds. For example, if we want our computer to turn off by itself in an hour, we will just write shutdown –s –t 3600.
The second method is to make a .bat script, which we insert into the scheduled tasks, to make it start at a specific time. Hence, the first step is to make a .bat script, which is actually quite simple. First open the notepad, write “shutdown –s” in it and save the document with the arbitrary name and .bat extension, for example “Turn me off.bat”.
After that, we open the “Scheduled Tasks” in the “Accessories” menu of the “System Tools” folder. A window will appear where you can click to “Add Scheduled Task”. Now click “Next”, find your script by clicking the “Browse” button, and choose when you want the script to be activated. Click “Next” again, insert the time of the script activation, and click “Next” one more time. You will be asked to insert a password now if you have one. Click “Next” again and check “Open advanced properties…”. Now you will have one more Advanced properties window, where you need to check “Run only if logged on” near to its bottom. The last operation you are performing is when you do not have the password on your computer, as the script would not start otherwise. In case you entered a correct password in the previous step, there is absolutely no need to open the Advanced properties menu.
After all this is done, the script will start up at the exact time you specified and the computer starts turning off after 30 seconds.
When for some reason you want to stop the process of turning of the computer once when it has already started, enter “shutdown –a” in Run and press Enter.
Similar Articles:
How to Shutdown and Restart Windows with shutdown.exe command-line application
Tags | Howto, Programming, Tools, Windows