Problems with users holding open Remote Desktop Sessions…?

By | 21 November, 2008

We have a problem at work when people are remotely adminstering Windows servers with Remote Desktop technology (aka Terminal Services). Instead of logging off, they can leave sessions open but just disconnected. So how do we get round this? (Windows Servers have a connection limit of two users, unless its a properly configured Terminal Server).

What I do is use Sysinternals PsExec utility along with some command line tools to logoff those users and enable access.

PsExec allows a user to run a remote command on a server, so what we do is spawn off a command shell remotely…

  1. Download psexec.exe from http://live.sysinternals.com
  2. Open a cmd.exe (Start > Run….. cmd.exe)
  3. Cd to where you downloaded psexec.exe and type
  4. psexec \\<servername> -u <user> -p <password> cmd.exe

  5. You should now effectively have a cmd.exe running on the remote server (type hostname and press enter, will tell you “where” you’re cmd.exe is running).

There is a couple of commands we can run now

Query Session – Shows us which users are connected to which terminal server sessions

Query Process – Shows us which processes are being run by which users

Reset <Sessionid> – This will reset the disconnected sessions (you can get the sessionid from query session.

Leave a Reply