Windows computers are usually configured to lock the screen after some time of inactivity. This is especially inconvenient if the remote desktop session keeps disconnecting each time after a few minutes of being idle. The Windows registry holds the value for the screensaver timeout. A PowerShell script to change the screen saver timeout can be written easily.
How to Increase Screensaver Timeout
Open Regedit, and take a look in the HKEY_CURRENT_USER hive. The Registry values related to the screensaver, ScreenSaveTimeout, can be found. This registry value determines how long the system must be idle before the screensaver kicks in. By default, the screen saver kicks in after 600 seconds or 10 minutes of inactivity. to modify this default screensaver timeout setting, supply the screen timeout as an integer value in the following script.
Script
<#
.SYNOPSIS
This script can be used to set the Screen Saver Timeout interval.
.DESCRIPTION
This script can be used to set the Screen Saver Timeout interval.
.EXAMPLE
C:\PS> C:\Script\Set_Screen_Saver_Timeout.ps1 100
Sets the ScreenSaverTimeOut value as 100.
#>
Param([int]$value)
$path = ‘HKCU:\Control Panel\Desktop’
$name = ‘ScreenSaveTimeOut’
#To get the ScreenSaveTimeOut value.
$old_value=(Get-ItemProperty -path $path -name $name).$name
echo “Old ScreenSaveTimeout: $old_value”
#To set the new ScreenSaveTimeOut value.
Set-ItemProperty -Path $path -name $name -value $value
#To get the new ScreenSaveTimeOut value.
$new_value=(Get-ItemProperty -path $path -name $name).$name
echo “New ScreenSaveTimeout: $new_value”