Make screensaver registry changes take effect immediately in Windows XP

I know I can change the settings for the screensaver in Windows XP from the command line by updating the registry as follows:

regedit.exe /s settings.reg

Where settings.reg contains:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop]
"ScreenSaveTimeOut"="7200"
"SCRNSAVE.EXE"="C:\\WINDOWS\\system32\\scrnsave.scr"

However, the settings do not take effect until I log out and back in. If I change the settings via Display Properties they take effect immediately.

Yes, it is Windows XP. Yes, there's a reason for it.

I know about SetScrTimeout.exe so I know it can be done. I can't use that tool on my system though and would prefer something homegrown.

How can I make these changes take effect immediately when changing the registry from the command line?


Solution 1:

While Windows stores the screensaver configuration in the registry, it doesn't check it for changes constantly. That would be rather inefficient.

The correct way to change the configuration is using the SystemParametersInfo function of Win32. For convenience, the desktop control panel DLL exports a function that is easily accessed from the command line that will call that function for you. Just run the following command:

rundll32.exe desk.cpl,InstallScreenSaver file.scr

That being said, the following command should force Windows to reread the configuration from the registry:

rundll32.exe user32.dll, UpdatePerUserSystemParameters

As an aside, you might find it easier to modify the registry from the command line by using the REG command, rather than writing .reg files all the time.