• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1230
  • Last Modified:

VB Script to Set a Screensaver on XP PCs

I am looking for a VB Script that will allow me to set the screensaver for the current user to a file located in the windows\system32 folder on XP PCs.
2 Solutions
Paste the script below into a text file with a .vbs extension.  Customize the value of the strFile variable with the name of the desired .scr file.  Running the script will change the screen saver setting in the registry.

It's usually easier to manage this kind of thing through the Group Policy node User Configuration\Administrative Templates\Control Panel\Display.

Const HKEY_CURRENT_USER = &H80000001
strFile = "logon.scr"
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSystemFolder = objFSO.GetSpecialFolder(1)
Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
strKeyPath = "Control Panel\Desktop"
strValueName = "SCRNSAVE.EXE"
strValue = strSystemFolder & "\" & strFile
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue

Open in new window

You'll also probably want to explicitly set the time delay for the screensaver as well to override anything the user may have set (or override the default 10 minutes) with a delay of your choosing.

Using Shift-3's code format for consistency, you can add the following to it:
'scrnsaveDelay's value is based on number of seconds,
'eg. 120 seconds = 2 minutes.
Const scrnsaveDelay = 120
strTimer = "ScreenSaveTimeOut"
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strTimer, scrnsaveDelay

Open in new window


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now