Greg Young [MVP]

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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

Posted Thu, Dec 20 2007 7:48 AM by Greg

[Advertisement]

Comments

Rune wrote re: RD Stuck?
on Thu, Dec 20 2007 8:20 AM
How about just using the /console switch to connect to the server - or is that not a viable option?
IainP wrote re: RD Stuck?
on Thu, Dec 20 2007 9:44 AM
The other option to do is in AD you can tell accounts to log off of TS if inactive for an amount of time
Mike wrote re: RD Stuck?
on Thu, Dec 20 2007 10:07 AM
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
Jason Haley wrote Interesting Finds: December 20, 2007
on Thu, Dec 20 2007 10:44 AM
The Other Steve wrote re: RD Stuck?
on Thu, Dec 20 2007 10:55 AM
Or grab the windows 2003 admin tools and run Terminal Services Manager. still, doing command line makes you an uber-geek
Greg wrote re: RD Stuck?
on Thu, Dec 20 2007 1:18 PM

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.

Joshua Flanagan wrote re: RD Stuck?
on Thu, Dec 20 2007 1:44 PM
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
Ian Nelson wrote re: RD Stuck?
on Fri, Dec 21 2007 5:02 AM

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

Christopher Steen wrote Link Listing - December 20, 2007
on Fri, Dec 21 2007 8:14 AM

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

Christopher Steen wrote Link Listing - December 20, 2007
on Fri, Dec 21 2007 8:14 AM

Link Listing - December 20, 2007

Caminews » Remote Desktop logoff wrote Caminews » Remote Desktop logoff
on Fri, Dec 21 2007 10:10 AM

Pingback from  Caminews » Remote Desktop logoff

Caminews » Remote Desktop logoff wrote Caminews » Remote Desktop logoff
on Fri, Dec 21 2007 11:10 AM

Pingback from  Caminews » Remote Desktop logoff

Caminews » Remote Desktop logoff wrote Caminews » Remote Desktop logoff
on Fri, Dec 21 2007 12:10 PM

Pingback from  Caminews » Remote Desktop logoff

Dave Woods wrote re: RD Stuck?
on Fri, Dec 21 2007 12:40 PM
The /console flag has saved me many a time: mstsc /v:ServerAddress /f /console (the /f is for full screen)
Caminews » Remote Desktop logoff wrote Caminews » Remote Desktop logoff
on Fri, Dec 21 2007 1:10 PM

Pingback from  Caminews » Remote Desktop logoff

Caminews » Remote Desktop logoff wrote Caminews » Remote Desktop logoff
on Fri, Dec 21 2007 2:10 PM

Pingback from  Caminews » Remote Desktop logoff

Bite my bytes wrote Links of the week #16 (week 51/2007)
on Sun, Dec 23 2007 6:14 PM

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

mikedopp wrote Mike's Links Monday (Post Christmas 2007)
on Thu, Dec 27 2007 3:19 AM

Mike's Links Monday (Post Christmas 2007)

http://30649.aspx.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://30649.aspx.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Thu, Mar 20 2008 1:54 AM
http://ado.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://ado.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Fri, Mar 21 2008 2:24 AM
http://rails.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://rails.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Fri, Mar 21 2008 2:25 AM
http://httphandler.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://httphandler.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Sun, Mar 23 2008 3:23 AM
http://146245.biztalk.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://146245.biztalk.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Wed, Mar 26 2008 4:53 AM
http://scrum.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://scrum.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Thu, Mar 27 2008 5:25 AM
http://firefox.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://firefox.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Fri, Mar 28 2008 5:56 AM
http://www2.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://www2.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Sat, Mar 29 2008 6:25 AM
http://nhibernate.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://nhibernate.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Fri, Apr 4 2008 9:23 AM
http://loopback.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx wrote http://loopback.codebetter.com/blogs/gregyoung/archive/2007/12/20/rdp-stuck.aspx
on Wed, Apr 9 2008 11:53 AM
The Daily Grind 1300 | Games Infomation wrote The Daily Grind 1300 | Games Infomation
on Thu, May 22 2008 5:50 PM

Pingback from  The Daily Grind 1300 | Games Infomation

Masood wrote re: RD Stuck?
on Thu, Feb 12 2009 10:31 AM
Awesome! It works in a fantastic way, Thanks for sharing :)

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us