Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ScreenSaveTimeOut registry not updating Windows - doing via vb script

Posted on 2007-10-12
9
Medium Priority
?
5,149 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.
0
Comment
Question by:ltlbearand3
  • 4
  • 3
  • 2
9 Comments
 
LVL 66

Expert Comment

by:johnb6767
ID: 20067273
Is this something you are rolling out for many PC's?  

Any GPO's already in place?

0
 
LVL 66

Expert Comment

by:johnb6767
ID: 20067289
Reason I ask, is this can be controlled by GPO, at User Config/Administrative Templates/Control Panel/Display/Screen Saver Timeout
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20067323
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
0
Independent Software Vendors: 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!

 
LVL 20

Author Comment

by:ltlbearand3
ID: 20067528
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.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20067597
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
0
 
LVL 20

Author Comment

by:ltlbearand3
ID: 20067734
This Batch does the same thing.  Updates everything in GUI except the Time Out value.  However, the value is updated in the registry.
0
 
LVL 12

Accepted Solution

by:
chandru_sol earned 2000 total points
ID: 20067836
Try this version, it works....

@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 600 seconds (10 minutes).
:REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaveTimeOut /T REG_SZ /F /D 600

REG ADD "HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop" /V ScreenSaveTimeOut /T REG_SZ /F /D 600
:: 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
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20067856
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
0
 
LVL 20

Author Comment

by:ltlbearand3
ID: 20068180
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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question