We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

VB Script to Set a Screensaver on XP PCs

zabac
zabac asked
on
Medium Priority
1,264 Views
Last Modified: 2012-08-13
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.
Comment
Watch Question

Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
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

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.