I’m working with a situation where all of the computers in a computer lab are actually zero-clients connecting to a dedicated Windows 7 VM on a server cluster.
This environment has its complexities, and I’m working to improve the performance.

That being said, I would get frequent notices from the Instructor that the computers would be running slow.

  • Rebooting the VMs would fix that, but it appeared that was just a Band-Aid.

I noticed that each VM would hold on to the disconnected RDP sessions and continue to consume resources in the background. Given that the Computer Lab terminals would RDP to a Windows 7 VM that was unshared, it was odd to me that more than one session would remain. I guess the users aren’t fully logging out of their sessions… This being a sensitive environment already, there were no resources to spare for these inactive sessions.

How do you terminate them automatically?

I started looking into a way to terminate the idle RDP sessions and found the perfect method through GPO. It has actually been around for years, but I can confirm it (still) functions in a Windows Server 2012 R2 environment with Windows 7 VMs.


Create the GPO:

In your group policy console, navigate to or create and link a policy that applies to your target computers (the hosts you would like to kill disconnected RDP sessions for)

Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits

Open Session Time Limits and enable the following policy:

  • Set time limit for disconnected sessions

Once enabled, you’re allowed to select from a drop-down after how long you would like to end a disconnected session.

Apply the changes and go ahead on to test, or force group policy updates to those hosts.


How do I know it works?

I set the time to 1 minute and applied the GPO to a test VM.

I logged into this VM three times remotely and once from the console.


I decided to close the first of three RDP sessions, without logging off. Here it shows disconnected:

After a minute, to my delight, the session was gone!


So, I disconnected the other two sessions :

and confirmed they were terminated automatically as well:

As Apache would say:


It works!


After testing:

I chose to set the interval to 30 minutes:

I forced a group policy update on all of the VMs.

Now we won’t see masses of idle disconnected sessions consuming resources on our server cluster.



This will not work for physical/console sessions, only sessions over RDP. This is functional in the example environment because the only method for the user to access the workstation is via RDP protocol, and they mainly close their session without logging off.


sisindri · July 16, 2019 at 6:03 am

Is there any possibility to set this time to less than a minute (means it will be immediate logoff when disconnect remote session). as per first screen shot in above explanation

James M · April 19, 2019 at 5:26 pm

I did not get the same test results. I do not believe the session logs the user off. My testing using Quser was disconnect only. Furthermore I was able to log back into the server that was disconnected and my apps were still open

It should be easy but it is Microsoft. This means nothing is always straight forward and a small thing like this needs to be tested in a lab – what I am doing

Here is an article for the log off utility. I find it silly, altough not surprised it is harder than it should be. It usually is with MS


    Tyler Woods · April 19, 2019 at 5:36 pm

    Thanks for your input. I understand what you’re saying about Microsoft and things not being simple, however, many MSPs and system administrators will not use free 3rd party utilities like you suggest in their production environments.

    It would be my advice to proceed with a GPO method and ensure your GPO is applying to the target machine.

    If you want to experiment more in lab, you could also try to use the GPO method for auto log off “active but idle” RDP sessions, as opposed to “disconnected” sessions. It’s the next configurable entry in the realm.

Leave a Reply