Howto: Remotely disconnect a Terminal Services Session

[update 2008-08-06]
I’ve written about another method for remotely disconnecting a terminal server session can be found here.

Windows server 2000/2003 allows two remote terminal services connections for administrative purposes.  Every once in a while I’ll get the “You exceeded the allowed connection count” message when trying to connect to a server via RDP, because previous sessions were not disconnected correctly.

You can use either of the following methods to remotely disconnect Terminal Server sessions.

Method 1

You can normally run the Terminal Services Manager program on another server, or even from a Windows XP workstation, to disconnect Terminal Services connections by clicking StartRun and then typing


This will launch the local copy of Terminal Services Manager.  Next right click on All Listed Servers and select Connect to Computer.  Type in the name or IP address of the server you wish to manage. 

 All Listed Servers in Terminal Services Manager

Select your server from the left pane, then select the Sessions tab from the right pane.  Right click on the session you wish to disconnect and select Disconnect.

You should now be able to login to the target server via Terminal Services.

Method 2

Authenticate to the server you wish to manage.  You can easily accomplish this by mapping a network drive to a share on the target server.  Start a command prompt and type

qwinsta /server:yourservername

where yourservername is the name or IP address of the server you wish to manage.

In my case I ran qwinsta /server:

You can see the Administrator account is logged into session 0 and the admin account is logged into session 1.  To disconnect the admin session with ID=1 I’ll run the following from a command prompt:

rwinsta ID /server:yourservername

where ID is the process ID of the sesstion you wish to terminate, and yourservername is the name or IP address of the server you wish to manage.

In my case I ran rwinsta 1 /server:

I again ran qwinsta /server: which verified session 1 had been disconnected.  I confirmed that I was once again able to login to Terminal Services.

Thanks to Ingo for some of the information, which I found via Andy.

14 Responses to “Howto: Remotely disconnect a Terminal Services Session”

  1. Anthony Brown Says:

    Very detailed and helpful article. Most articles of a technical nature leave out steps, thanks for being concise.

  2. Rich Says:

    Love the command-line trick. Very cool.

    Another way to deal with “too many users connected” is to use the console to connect.

    mstsc /v:targethost /console

    We had a policy at a few shops I’ve worked at that, on production servers, admins only connect to the console session.

  3. bamba Says:

    In Windows Vista and 2008 there is a newer version of mstsc which hasn’t /console parameter anymore. You have to use /admin parameter instead:
    mstsc.exe /v:servername /admin

  4. Joel Maust Says:

    Thanks for the tip; very helpful.

    One note, though, is that you first spell “rwinsta” without the “n”. And that caused the command to not work until I figured out that it was supposed to have the “n” in it.

    You spell it right the second time, so it’s not a big deal and I’m sure people figure it out… just thought I’d point it out.

    Thanks again.

  5. Julie Says:

    Thanks for pointing that out Joel. I’ve fixed the problem.


  6. Average Jake | Monitoring and Terminating Remote Desktop Connections Says:

    […] the original article here: Categories : Utilities trackback comments […]

  7. Brian Says:

    Nothing constructive to add but I just wanted to say thanks, I have tried for ages to find something like this and this is the best article by far.

    Thank you!

  8. Jon Says:

    Thanks @ Bamba ; the /admin change threw me after a force rollout of the new ts client at work!

    Whhhyyyy will me /console command not work??? *shakes fist* All fixed now

  9. Ramesh Says:

    Great Solution. Thanks for detailed instructions.

  10. DISTURBED690 Says:

    Great knowledge share! Thanks a lot!

  11. Mohammad Says:

    Cool ! Big Thanks

  12. Rob Weinstein Says:

    Thanks a lot. Ran into this a bunch of times and didn’t know how to fix it remotely and never bothered to look it up until today.

  13. Young K Says:

    Thanks. I run into this every now and than, and I keep forgetting the commands.

  14. Yaarik Says:

    This is a lifesaver on Windows 7 where I don’t have tsadmin.exe.

    Thank You!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: