(How) can I change the time until the screensaver kicks in from the command line?

As the title asks (Windows 7). (How) can I change the time until the screensaver kicks in from the command line? Is it even possible?

Normally I am happy with a 5 minute setting, but occasionally I want to make it longer. I would like the two lengths bound to hot-keys (I know how to do that).

I guess I could record two macros and use those, but I just wondered if there are any command line options (including registry updates) that I can use to tell Windows to start the screen saver after X minutes of inactivity.

(please note, I do not want to start the screen saver immediately; I want to change the length of time Windows will wait before starting it)

Thanks in advance.


[Answer] I finally used a variation on the answer from @Gjordis - but all credit goes to him.

I didn't see why we needed 3 operations : add, delete then rename and reduced that to two.

Since I want to bind to a hotkey, I need to execute two comamnds in one. Normally, one can separate the commands with a semicolon and issue them on one line (e.g dir c:;dir d:). That gave errors with the reg command, so in the end I have two batch files. The contens are identitcal, only the duration changes.

On strange thing - the value is correctly written to the registry, but Control Panel/Personalize/Screen saver does not alwys update its GUI. However, I tested and the screen saver does behave as expected.

@echo off
reg delete "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 180 /f

If this helps you, please upvote the question ;-)


reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 600 /f

The value 600 is in seconds, = 10minutes Interestingly, as pointed, this works only the first time. On next change, you need to make a new key like so :

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOutTemp /t REG_SZ /d 300 /f

Then delete the old one

reg delete "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 600 /f

Then copy the new one to the right name

reg copy "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOutTemp "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut

Hopy this works, and you do not destory your computer, but since you did not have this registry value, i don't think deleting it can be that horrible.

REG documentation here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/reg.mspx?mfr=true


In fact, this approach (via registry) doesn't work until reboot. Only way to do that without PC reboot is to use an API:

https://www.pcreview.co.uk/threads/utility-to-temporarily-change-the-screensaver.2321339/#post-7442568

but APIs can't be used from a command line, i.e. VB script. Here is the reason:

http://forums.codeguru.com/showthread.php?31534-VBScript-and-API&p=86696#post86696

It could be done by calling utility SetScrTimeout.exe (from the first link), but unfortunatelly, this small utility doesn't exist on internet anymore.