[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 Start – Run and then typing
%SystemRoot%\system32\tsadmin.exe
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.

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:10.0.0.2
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:10.0.0.2
I again ran qwinsta /server:10.0.0.2 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.


{ 13 comments… read them below or add one }
Very detailed and helpful article. Most articles of a technical nature leave out steps, thanks for being concise.
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.
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
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.
Thanks for pointing that out Joel. I’ve fixed the problem.
-Julie
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!
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
Great Solution. Thanks for detailed instructions.
Great knowledge share! Thanks a lot!
Cool ! Big Thanks
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.
Thanks. I run into this every now and than, and I keep forgetting the commands.
This is a lifesaver on Windows 7 where I don’t have tsadmin.exe.
Thank You!
{ 1 trackback }