Tuesday, March 12, 2013

Windows 7 Screen Saver Quenching for Kiosks

Here's a powershell script which stops the screen saver. Handy in an enterprise where screen savers are enforced by group policy. Used this for a machine set up as an annunciator/dashboard.
#
# This script emulates a user pressing the Num Lock key every two seconds. 
# When working the Num Lock light will flash on the keyboard. It will affect
# the behaviour of the numeric keypad
#
# This tricks the windows screen saver into thinking there is an a active user
# hence it prevents the screen saver. Do not use in a secured situation.
#
# For details see http://technet.microsoft.com/en-us/library/ee156592.aspx
#
$shell = New-Object -com "Wscript.Shell"

while ($True) {
  $shell.sendkeys("{NUMLOCK}")
  Start-Sleep -Seconds 2
}