CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Greg Young [MVP]


RD Stuck?

 

Oops

I only get these "Terminal server has exceeded the maximum number of connections" when its 3 am and I am dealing with a production problem where I absolutely need access at that moment. Naturally any admin etc is sleeping and unavailable. Personally walking to the office in my jammies is something I like to avoid so I figured there had to be a better way to get around it and there is. perhaps this is not interesting but I would have bookmarked this a while ago if I had seen it before.

Step 1: Download psexec from microsoft http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

Step 2: Unzip into a folder (let's say c:\pstools)

Step 3: psexec \\yourserver -u yourusername -p yourpassword qwinsta you will get an ouput like this:

C:\PsTools>psexec \\MyServer -u gregy -p YeahRight qwinsta

PsExec v1.93 - Execute processes remotely
Copyright (C) 2001-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>console                                     0  Conn    wdcon
rdp-tcp                                 65536  Listen  rdpwd
                   user1                     1  Disc    rdpwd
rdp-tcp#21        user2                     2  Active  rdpwd
qwinsta exited on MyServer with error code 0.

Output Qwinsta

Step 4: Kill a connection. Grab the ID field in the above and use it in psexec \\yourserver -u yourusername -p yourpassword logoff ID /v

C:\PsTools>psexec \\MyServer -u gregy -p YeahRight logoff 2 /v

PsExec v1.93 - Execute processes remotely
Copyright (C) 2001-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

Logging off session ID 2
logoff exited on \\MyServer with error code 0.

Output of log off


Comments

Rune said:

How about just using the /console switch to connect to the server - or is that not a viable option?
# December 20, 2007 8:20 AM

IainP said:

The other option to do is in AD you can tell accounts to log off of TS if inactive for an amount of time
# December 20, 2007 9:44 AM

Mike said:

Already addressed awhile ago but still useful. http://labs.redbd.net/blog/index.cfm/2007/7/31/Easily-kill-remote-desktop-sessions-to-your-server
# December 20, 2007 10:07 AM

Jason Haley said:

# December 20, 2007 10:44 AM

The Other Steve said:

Or grab the windows 2003 admin tools and run Terminal Services Manager. still, doing command line makes you an uber-geek
# December 20, 2007 10:55 AM

Greg said:

This is why I am not a system admin (well that and the fact that I would forget the 37 character admin password) :)

Benefit to my solution? I now have a script to do it.

# December 20, 2007 1:18 PM

Joshua Flanagan said:

I don't get why you need to use psexec to run qwinsta, instead of the /server parameter. Is there an advantage to: psexec \\MyServer -u gregy -p YeahRight qwinsta over: qwinsta /server:MyServer and then to kill a connection rwinsta [ID] /server:MyServer
# December 20, 2007 1:44 PM

Ian Nelson said:

What Rune said - why not just use the /console switch?

# December 21, 2007 5:02 AM

Christopher Steen said:

ASP.NET How-To: New ASP.NET 3.5 Extensions Video Screencasts [Via: Scott Hanselman ] Link Blogs Links...

# December 21, 2007 8:14 AM

Christopher Steen said:

Link Listing - December 20, 2007

# December 21, 2007 8:14 AM

Caminews » Remote Desktop logoff said:

Pingback from  Caminews » Remote Desktop logoff

# December 21, 2007 10:10 AM

Caminews » Remote Desktop logoff said:

Pingback from  Caminews » Remote Desktop logoff

# December 21, 2007 11:10 AM

Caminews » Remote Desktop logoff said:

Pingback from  Caminews » Remote Desktop logoff

# December 21, 2007 12:10 PM

Dave Woods said:

The /console flag has saved me many a time: mstsc /v:ServerAddress /f /console (the /f is for full screen)
# December 21, 2007 12:40 PM

Caminews » Remote Desktop logoff said:

Pingback from  Caminews » Remote Desktop logoff

# December 21, 2007 1:10 PM

Caminews » Remote Desktop logoff said:

Pingback from  Caminews » Remote Desktop logoff

# December 21, 2007 2:10 PM

Bite my bytes said:

Links of the week #16 (week 51/2007)

# December 23, 2007 6:14 PM

mikedopp said:

Mike's Links Monday (Post Christmas 2007)

# December 27, 2007 3:19 AM

The Daily Grind 1300 | Games Infomation said:

Pingback from  The Daily Grind 1300 | Games Infomation

# May 22, 2008 5:50 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!