remotely log off terminal services session using CMD prompt

Windows server 2000/2003 allows two remote terminal services connections for administrative purposes.  Every once in a while you might get the message “You exceeded the allowed connection count” message when trying to connect to a server via RDP (Remote Desktop Protocol), because previous sessions were not disconnected correctly. To resolve this so we can connect, we need to disconnect in-active sessions through terminal service manager, but what can we do in the case where all sessions are still active?  To resolve this you can follow the below simple solution to quickly remotely log off a terminal services connection via command line from you PC.

If a terminal server has exceed the maximum number of sessions an “/admin” session can still be created and this will allow you to still connect to the server.

The /admin sessions don’t count towards the session limit that may be configured on a terminal server to limit the number of remote sessions, so this will give you a back door into the server if you get the message “The terminal server has exceeded the maximum number of allows connections”.

In this example you can see 2 users, Matt and James, that are have had a previous RDP session and are in a disconnected state and the server will not allow any further connections.

Using 2 commands you can easily remotely log off terminal services connections

Command 1 – qinsta /server:yourservername – this will display the users that are logged in along with their session ID. You can see below that James has the session ID of 2.

Command 2 – rwinsta 2 /server:yourservername – This will log off user with session ID of 2

Once these steps have been completed you will now be able to start a terminal services session and log in successfully to the Windows server.

Leave a Reply

Your email address will not be published. Required fields are marked *