Category filter

Script to Change Screensaver Time on Windows

A screensaver is set to turn on after a period of inactivity of the user. It is important to protect your devices when unattended as it is vulnerable to potential intruders. A screensaver prevents someone from viewing your personal files and can also be used as a medium to display your brand when idle. You can set a time delay for inactivity before the preset screensaver kicks in with Hexnode’s custom script feature.


The Sample Scripts provided below are adapted from third-party Open-Source sites.

PowerShell Script

The script takes input $timeLimit in seconds and modifies the wait time for the screensaver already set by the user on the device to take effect.

The script works by modifying the registry to change InactivityTimeoutSecs at the path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\.

Time delay is set in seconds. If not provided, the script returns an output to enter the inactivity limit in seconds as an argument.

Batch Script

The reg add command will create a REG_DWORD under the location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System. Replace <time> with an integer value ranging from 0 to 599940, indicating the wait time for the screensaver already set by the user on the device to take effect. The restriction will take effect after the device restarts. You can use the Restart Device action to remotely initiate a device restart.

For example:

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v InactivityTimeoutSecs /t REG_dWORD /d 60 /f


  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository