< Annoy your little sister or brother >

Automatic PC-shutdown after a given time

This is a small Visual Basic Script (VBS) to shut down or restart the computer after a specified time.
The script is ment for little sisters or brothers who are sitting too long in front of the screen. If the PC shuts down regularly they will hopefully look for another occupation (or deal with the technology even more).

' Schwester1.vbs

Const intZeit = 5400000 ' 1,5h = 5.400 sec = 5.400.000 msec
WScript.Sleep intZeit

Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run("shutdown.exe -s -t 01 -f")

If you want to make it more exciting you can use the second script with a random delay. The following example waits between one and two hours until it shuts down the computer.

' Schwester2.vbs

Const intMax = 7200000 ' max. 2h = 7.200 sec = 7.200.000 msec
Const intMin = 3600000 ' min. 1h = 3.600 sec = 3.600.000 msec

Randomize
intZeit = Int((intMax - intMin + 1) * Rnd + intMin)
WScript.Sleep(intZeit)

Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run("shutdown.exe -s -t 01 -f")

Explanation

Const intZeit
Const intMax
Const intMin
Variable for the time (Zeit) in milliseconds (1/1000 sec).
Randomize Generator for random numbers
WScript.Sleep(intZeit) Sleep-function of the Windows Scripting Host (version 5.1. and above) waits a specified time for the next order.
Set objShell Shell object to execute programs.
objShell.Run("shutdown.exe -s -t 01 -f") "Shutdown"-command to shutdown (-s) the system after one second (-t 01) and force (-f) all applications to quit.

The "Shutdown"-command is built in Windows XP and later (Vista, Win 7) and can be started on the command line. (Type shutdown /? on the command line (cmd) for a full list of options.) For older Windows versions (2000, 98, 95, NT 4.0) you can find several shutdown-programs with a similar handling on-line.

Attention/Disclaimer!

Task-Manager
  • While shutting down the PC you may lose unsaved documents.
  • The program can't be seen in the Task Manager (Ctrl+Alt+Del) under the point "Applications".
  • To stop it you have to use the Task Manager > Processes > and end the "wscript.exe".

Download

You can download the scripts for free.


Related topics: Downloads All 16M colors Autostart PW-Finder

Rate page:  
  -/5 Points (4 Ratings)
-/5 4