Lost Remote Desktop connection prevents computer from sleeping
This is an issue I can't find any info about. I have a Windows PC set up so that, even if I log in remotely, it falls asleep after a while. And this works fine with one exception: when the computer I'm connecting from goes to sleep while Remote Desktop is open (e.g. I close the lid), it somehow prevents the remote computer from sleeping.
I guess the Remote Desktop service prevents sleep after a lost connection so you can't lock yourself out by accident, but I don't think this behaviour makes sense when it's configured to sleep while the session is open.
This is annoying because I sometimes forget to log off before I close the lid on my laptop, and then my PC stays idle for hours until I notice. Is there a workaround for this? For reference, both computers are running Windows 10 20H2 build 19042.804.
Posted Feb 18, 2021, 2:30 PM UTC
this certainly isn't the answer you're looking for, but log off/close the RDP session before you log off or close your laptop.
​
Leaving that connection running when you close/log off the laptop is bad practice and the "workaround" you're looking for is a method to support that bad practice, trying to follow and use good habits (like logging off the remote connection prior to the local) is your "correct" answer/solution.
​
That being said, if you really want it do this, a "Workaround" would be to create a task to run "RUNDLL32.EXE powrprof.dll,SetSuspendState 0,1,0" when idle for X number of minutes/hours. That command will put the machine to sleep mode, and the task settings has properties to start the task only if idle for "x minutes/hours".
Could you expand on why is it such a bad practice? Both computers are on a home network (the PC is next room) and I'm not even logging off from the client.
Plus, there're other reasons why this could happen (laptop sleeps after a shorter timer, home router freezes because it's shitty). I just don't think pretending the user is always capable of logging off is a valid expectation for any piece of software.
It is a perfectly valid expectation... especially in an environment where there limits due to licensing constraints, resources, etc. etc.. There many instances where logging off the software is not only a valid expectation, but a requirement. For home use, that's less of a concern in most cases, but can still be applied.
​
As for good vs. bad, a lot of that spawns from a more business related environment than a personal/home setup, but there are certain best practices that do translate and carry over. Locking your computer when stepping away, closing out remote sessions and not leaving them running, etc. etc., those are basic best practices in many environments. Is it bad for home use, no not really, but often times, habits carry over. If you have a job working with computers, remote sessions, etc. etc., and you're in the habit of just closing and leaving stuff running at home, you're more likely to do so on the job as well, where it could have much more impact.
​
Some of the scenarios are specific, and may not be applicable, it's just a "general" best practice thought. Like eating healthy or exercising regularly... everyone needs to eat right and stay in shape, but some need it more than others, so they may have stricter diets or more aggressive exercise regimens, so on and so forth