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

10

5

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 ;-)

Mawg says reinstate Monica

Posted 2013-03-05T07:34:17.960

Reputation: 2 744

Answers

7

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

Gjordis

Posted 2013-03-05T07:34:17.960

Reputation: 444

That works :-) The first time only :-( presumably because I didn't have a registry entry the frist time, so could add, but might need to modify subsequently? +1 for trying. Thanks – Mawg says reinstate Monica – 2013-03-05T08:04:08.797

1Edited to hopefully work other times too – Gjordis – 2013-03-05T08:14:59.863

+1 Well, that's trange. I can see that it is updating the registry key, but when I right click the desktop (or go via control panel) and choose "peronalize", it still shows 5 mintes on the GUI. If I set 10 seconds via registry, the screen saver does not start after 10 seconds (or even a few minutes). If I set 1 minute in the GUI then it does start after 1 minute (and it updates the registry correctly). – Mawg says reinstate Monica – 2013-03-05T08:44:32.383

Perhaps it has a valid value -range – Gjordis – 2013-03-05T08:46:50.400

+1 I used a variation on your answer and have posted it in the qustion above. Thanks for your help – Mawg says reinstate Monica – 2013-03-06T02:35:01.517

1

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.

Aleksandar

Posted 2013-03-05T07:34:17.960

Reputation: 27

Thanks for that. Perhaps SetScrTimeout.exe can be founds on the way back machine? I can't check because of the company firewall, but it should be there - everything else is ;-)

– Mawg says reinstate Monica – 2018-11-21T12:42:29.270

1

I even tried on ftp servers, but no result. I have found an VB source code for that purpose (http://www.freevbcode.com/ShowCode.asp?ID=504), but I am not able to make and share an exe.

– Aleksandar – 2018-11-22T12:00:10.460

Any idea which version of VB (I am guessing VN 6)? – Mawg says reinstate Monica – 2018-11-22T12:44:49.950

1Yes, it is VB6. Sorry for my late reply. – Aleksandar – 2019-11-04T08:43:06.833