Wednesday, February 17, 2010

How to View / Disconnect Remote Desktop Sessions from Commandline

I used to receive the maximum number of connections error message when I try to log on to the Windows 2003 Server in my office via Windows Remote Desktop.

“The terminal server has exceeded the maximum number of allowed connections“

Session Exceeded

This is pretty annoying if you have some urgent work to do in the server. Most of the already logged in users won’t even be using the session at the time, but I can’t login! So how to solve this? After a bit of googling, as usual, I found a simple way to disconnect other remotely logged in sessions. :D

First of all you must be logged in to your client computer as a domain Admin user. Now open the command prompt and type in the following command.

qwinsta /server:SERVERIP

The Ip address or domain name of the Remote server should be entered in place ofSERVERIP

Example:

qwinsta /server:10.10.1.10

You will get a list of the Remote Sessions in the command window.

Remote sessions list

In the above sceenshot we can clearly see an Active RDP session with the ID 2 which belongs to the user Administrator. In order to disconnect that user we are going to use the session ID. Use the following command line to disconnect the remote session.

rwinsta /server:SERVERIP SESSIONID

For example in order to terminate the session of the Administrator user the following command should be given.

rwinsta /server:10.10.1.10 2

Disconnect Remote Session

Now let’s confirm if the user is really disconnected. Just type in the qwinstacommand in proper format.

Disconnected Remote Sessions List

As you can see our session with ID 2 is no longer there. Now for the user we just disconnected will see the following message.

Disconnected-Server-Session

The remote session was disconnected because you session was logged off at the remote computer. Your administrator or another user might have ended your connection.

No comments:

Post a Comment