Q. How can a batch script alter the users screen saver and wallpaper settings and become effective without a logoff and logon?

Jerold Schulman

August 13, 2006

2 Min Read
ITPro Today logo in a gray background | ITPro Today

In tip 3259, I described the registry entries to configure a users wallpaper. In tip 1966, I described the registry entries to configure a users screen saver settings. In tip 0070, I described the registry entries to restrict changes to Display Properties.

When you change these registry entries, their impact is normally not effective until the user logs off and logs on. To force the above changes to become effective immediately, without the need to log off and log on, use the following command:

%SystemRoot%System32RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

Here is a sample script that can be run to change the current user's wallpaper and screen saver entries, preventing access to the relevant Display Properties tabs, and making the changes effective immediately.

NOTE: The sample code can even be included in a logon script.

NOTE: REG.EXE is built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools.

The SampleScript.bat contains:

@echo offcall :quiet>nul 2>&1goto :EOF:quiet:: Configure Wallpaper REG ADD "HKCUControl PanelDesktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%energybliss.bmp"REG ADD "HKCUControl PanelDesktop" /V WallpaperStyle /T REG_SZ /F /D 0REG ADD "HKCUControl PanelDesktop" /V TileWallpaper /T REG_SZ /F /D 2:: Configure the screen saver.REG ADD "HKCUControl PanelDesktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%System32scrnsave.scr"REG ADD "HKCUControl PanelDesktop" /V ScreenSaveActive /T REG_SZ /F /D 1:: Set the time out to 900 seconds (15 minutes).REG ADD "HKCUControl PanelDesktop" /V ScreenSaveTimeOut /T REG_SZ /F /D 900:: Set the On resume, password protect box REG ADD "HKCUControl PanelDesktop" /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 "HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem" /V NoDispScrSavPage /T REG_DWORD /F /D 1REG ADD "HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem" /V NoDispBackgroundPage /T REG_DWORD /F /D 1REG ADD "HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem" /V NoDispAppearancePage /T REG_DWORD /F /D 1:: Make the changes effective immediately%SystemRoot%System32RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like