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:
As per this solution, running rundll32.exe user32.dll, UpdatePerUserSystemParameters
, however the command is very inconsistent and most of the time doesn't work.
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.
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.