How to View / Disconnect Remote Desktop Sessions from Commandline

by Strider on January 26, 2009

in Tips 'n' Tricks

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 of SERVERIP

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 qwinsta command 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.

So we are done with the remote session management over command lines.

Related Articles:

  • X-NetStat Pro – View your Internet and network connections in realtime
  • How to use SSH (Putty) behind a Proxy/Firewall?
  • “Last account activity” – Find out who else is using your Gmail Account!
  • Mozilla Firefox Tips and Tricks
  • Recursively change only directory permissions on Linux (Chmod)
  • { 21 comments… read them below or add one }

    Pat April 14, 2009 at 5:31 am Thumb up 0 Thumb down 0

    This is good sharing!!!
    Thanks.

    Reply

    Kaiserskorpion April 14, 2009 at 7:36 pm Thumb up 0 Thumb down 0

    Excellent, this is very usefull!

    Thanks Bro!

    Reply

    gogon May 15, 2009 at 11:49 am Thumb up 0 Thumb down 0

    many thanks
    it works man!

    Reply

    gogon June 5, 2009 at 9:54 am Thumb up 0 Thumb down 0

    thanks a lot
    it works!

    Reply

    Hari August 22, 2009 at 1:59 am Thumb up 0 Thumb down 0

    Thanks a lot for sharing this info.

    Reply

    Pankaj September 10, 2009 at 10:55 pm Thumb up 0 Thumb down 0

    This tip saved a lot of headache for me today. Thanks a ton.

    Reply

    vip October 26, 2009 at 5:34 pm Thumb up 0 Thumb down 0

    Excellent Mate!!

    Reply

    ISP October 31, 2009 at 2:27 am Thumb up 0 Thumb down 0

    If you are a domain admin, you can just use the “SERVER /console” or “SERVER /admin” in the RDP dialogue so you can log on to the console instead. Much easier than remotly logging another admin user off.

    Reply

    Prakash Mannil November 3, 2009 at 5:53 pm Thumb up 0 Thumb down 0

    Thanks a lot buddy!!

    Reply

    Emme December 1, 2009 at 11:56 pm Thumb up 0 Thumb down 0

    Thank you that was very helpful and much appreciated!

    Reply

    Sean December 8, 2009 at 4:13 am Thumb up 0 Thumb down 0

    Please note that with remote desktop there is a difference between logging off a user and disconnecting a user. When you disconnect a user only the connection is dropped (marked as inactive) but the session is still active – all of the programs are left running.

    Task Manager has the option to either disconnect or logoff, so I’m still hoping to find a command line way to do the disconnect only.

    Reply

    Joao Bombril February 18, 2010 at 9:30 pm Thumb up 0 Thumb down 0

    Cheeeers

    thanks bro

    Reply

    Mar March 11, 2010 at 3:44 pm Thumb up 0 Thumb down 0

    great advice! commands work a treat!

    Thanks for sharing

    Reply

    Shriniwas.... April 1, 2010 at 11:25 am Thumb up 0 Thumb down 0

    Its good……….. it worked !!!

    Reply

    Albin Sebastian May 20, 2010 at 9:14 am Thumb up 0 Thumb down 0

    Hi,
    Thanks, This is very easy, I was using TSadmin – GUI to disconnect the sessions

    Reply

    Madhu..... June 26, 2010 at 3:05 am Thumb up 0 Thumb down 0

    Hi,

    Thanks a lot!!

    Reply

    bhaskar July 12, 2010 at 12:08 pm Thumb up 0 Thumb down 0

    it is really good

    thank you

    Reply

    happy July 15, 2010 at 6:01 pm Thumb up 0 Thumb down 0

    Saved me a lot of time!

    Thanks a lot!!!!

    Reply

    RomeO August 16, 2010 at 6:38 pm Thumb up 0 Thumb down 0

    thx a lot! Very usefull!

    Reply

    Jasbir August 22, 2010 at 9:58 am Thumb up 0 Thumb down 0

    Thanks, thanks, thanks, …

    Reply

    tony August 30, 2010 at 6:29 pm Thumb up 0 Thumb down 0

    Good explanation!

    Reply

    Leave a Comment

    Previous post:

    Next post: