10

How can I turn off the screensaver in RDP sessions and thus keep the session alive and unlocked, even if I am not actively working in it for some time?

Note: the solution should work without affecting the console itself. Only the RDP connections, please.

1

3 Answers 3

6

I was able to accomplish this with Task Scheduler.

  1. Open Task Scheduler. Right click Task Scheduler Library and Create Task

  2. Name: Disable RDP Screen Saver

  3. Triggers: New Trigger, On Connection to User Session, Specific user (specify user), From a remote computer

  4. Actions: Start a program,

  5. Program: reg

  6. Arguments: add "HKEY_CURRENT_USER\Control Panel\Desktop" /f /v ScreenSaverIsSecure /t REG_SZ /d 0

  7. Open Task Scheduler. Right click Task Scheduler Library and Create Task

  8. Name: Enable RDP Screen Saver

  9. Triggers: New Trigger, On disconnect from User Session, Specific user (specify user), From a remote computer

  10. Actions: Start a program,

  11. Program: reg

  12. Arguments: add "HKEY_CURRENT_USER\Control Panel\Desktop" /f /v ScreenSaverIsSecure /t REG_SZ /d 1

1

You can use the Registry Editor [Regedit.exe from command line] and find and edit the following key: HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveActive If your screen saver is currently enabled the value will be 1, change it to 0 to disable.


Before you make changes to a registry key or subkey, Microsoft recommends that you export, or make a backup copy, of the key or subkey. You can save the backup copy to a location you specify, such as a folder on your hard disk or a removable storage device. If you make changes that you want to undo, you can import the backup copy. More info here


4
  • Thans, but ... won't this actually also switch the screensaver off on the console? Which is exactly what I don't want ... Commented Oct 3, 2012 at 12:45
  • With Windows 7 there is no client session. You are effectively logging in to the console session any time you log in using RDP. This will force the remote machine to show the log-on dialog. Is your intent to have the monitor shut off or not display the desktop? Commented Oct 4, 2012 at 11:59
  • thanks. I think one is attaching to the console session, just like one can do explicitly with mstsc. However, this doesn't help solve the problem, does it? :) ... I'm about to write a program that sits in the tray and only activates when run inside the RDP session and then prevents the screensaver from starting. Commented Oct 4, 2012 at 13:29
  • 1
    Since this answer didn't answer your question, you should consider un-selecting it as an answer. You should accept BajaResident's answer, about TaskScheduler. Commented May 10, 2016 at 2:14
1

Unfortunately BajaResident's solution doesn't really work. Or rather, the 2nd task works but the first doesn't. This is because explorer.exe launches before the task runs when signing in and explorer.exe doesn't know the registry value was changed.

So there are 3 ways to force a reload of the values:

  1. As per this solution, running rundll32.exe user32.dll, UpdatePerUserSystemParameters, however the command is very inconsistent and most of the time doesn't work.

  2. Running a powershell script as some posts on the internet , however all examples are for things like changing the wallpaper and learning powershell and the API would be a bit of work.

  3. Restarting explorer.exe, however it hurts productivity a lot.

In the end I adopted the dirty way with option 1 with a batch script executing it in a while loop:

@echo off


set /a "screenSaverWhileLoop = 1"

:while
    if %screenSaverWhileLoop% lss 10 (
        timeout 2
        rundll32.exe user32.dll, UpdatePerUserSystemParameters
        set /a "screenSaverWhileLoop = screenSaverWhileLoop + 1"
        goto :while
    )

This will execute the command every 2 seconds for 20 seconds.

The issue now (and also if you do a powershell script) is that a CLI window will show up. You can start it minimized, but it will still be there.

The best solution I found for this was Hidden Start. From the scheduler you will run hstart64.exe with arguments /noconsole "c:\path\to\script.bat".

Not sure if needed, but I also added in both scheduler tasks to change the reg ScreenSaveActive to 0 on connect and 1 on disconnect.

Combine this with BajaResident's solution and it should work for you (it's working for me at least). I tested if disconnecting immediately after connecting would leave the screensaver off, but it didn't. Seems like the reload option only works if your user is currently signed in. I imagine it would cause issues if you connected via RDP and within 20 seconds logged in via console though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .