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

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%\System32\RUNDLL32.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 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


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish