We help IT Professionals succeed at work.

ScreenSaveTimeOut registry not updating Windows - doing via vb script

5,388 Views
Last Modified: 2008-04-25
I would like a vb script that can adjust my screen saver automatically.  My script currently updates the registry fine, but does not change the actual screen saver.  Also if I can the settings in the registry manually, it does not update the screen saver either.  However, if I change the settings through the GUI, I see the registry settings update (so I know I have the right values).  As best I can tell I need someway to get windows to update.  The ScreenSaverIsSecure value updates fine, but the ScreenSaveTimeOut does not update the GUI.  This is on WinXP sp2.  Any ideas?

Here is my current script:

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Control Panel\Desktop"
strEntryName = "ScreenSaverIsSecure"
strValue =  "0"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "ScreenSaveTimeOut"
strValue =  "900"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue


FYI - I use my laptop in multiple settings and I just wanted a quick script to change the screen saver in certain settings.
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
Is this something you are rolling out for many PC's?  

Any GPO's already in place?

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
Reason I ask, is this can be controlled by GPO, at User Config/Administrative Templates/Control Panel/Display/Screen Saver Timeout
Can you try this script?

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Control Panel\Desktop"
strEntryName = "ScreenSaverIsSecure"
strValue =  "0"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "ScreenSaveTimeOut"
strValue =  "900"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "SCRNSAVE.EXE"
strValue =  "screensaver"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "ScreenSaveActive"
strValue =  "1"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

or we can use GP to force the screensaver to all the users
CERTIFIED EXPERT

Author

Commented:
This is only for a few selected laptops and I want the user to be able to run the script to make the change then run a script to change it back.

The script I have does update the registry.  However, I have to log off and log back on for the changes to take affect.  Is there anyway to get Windows to update with the registry changes without the log off / log back on?  I would really like to do this via vb script.
Hi,
Can you try this batch file and see if it helps?

@echo off
call :quiet>nul 2>&1
goto :EOF
:quiet
:: Configure Wallpaper
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\energybliss.bmp"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 2
:: Configure the screen saver.
REG ADD "HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\scrnsave.scr"
REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
:: Set the time out to 900 seconds (15 minutes).
REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaveTimeOut /T REG_SZ /F /D 900
:: Set the On resume, password protect box
REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaverIsSecure /T REG_SZ /F /D 1
:: Remove the user's ability to see the Screen Saver, background, and appearance tabs of Display Properties.
:REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /V NoDispScrSavPage /T REG_DWORD /F /D 1
:REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /V NoDispBackgroundPage /T REG_DWORD /F /D 1
:REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /V NoDispAppearancePage /T REG_DWORD /F /D 1
:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
CERTIFIED EXPERT

Author

Commented:
This Batch does the same thing.  Updates everything in GUI except the Time Out value.  However, the value is updated in the registry.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Try this version of Vbscript if you want to use only vbscript.....

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Policies\Microsoft\Windows\Control Panel\Desktop"
strEntryName = "ScreenSaverIsSecure"
strValue =  "1"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "ScreenSaveTimeOut"
strValue =  "900"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "SCRNSAVE.EXE"
strValue =  "iconsave.scr"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

strEntryName = "ScreenSaveActive"
strValue =  "1"
 objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue
CERTIFIED EXPERT

Author

Commented:
The Dos script works great.  I just have to remove the registries in my undue script.  I had to change the VB script to use a write registry instead of set registry.  The concept works great though.

Here is a fixed VB script

strComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
   
Set SysVarReg = WScript.CreateObject("WScript.Shell")

RegPath = "HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\"

strEntryName = "ScreenSaverIsSecure"
strValue =  "1"
SysVarReg.RegWrite RegPath & strEntryName, strValue

strEntryName = "ScreenSaveTimeOut"
strValue =  "900"
SysVarReg.RegWrite RegPath & strEntryName, strValue

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*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.