Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently we do some development and monitoring over 1 RDP account (administrator) to a server 2008 r2 machine, as everyone needs to share the same instance of everything to ensure consistency. The problem is that while one person is connected and working away, if someone else tries to connect using the same account, it will boot the first person off and yield control to the second person. The only warning comes a bit too late, when the first person receives a message saying "Another user connected to the remote computer, so your connection was lost".

Is there any known way to warn the incoming user that someone is already connected (similar to the type of message you might get when working with different accounts), or to allow the victim the option of not being booted?

share|improve this question
up vote 5 down vote accepted

Some bad news for you: There is no way to get RDP to warn you when you are about to log in to an existing session. It only warns when you are going to log in via RDP and another user is already logged in. sad face

Wait... it might be theoretically possible using remote scripting. You can use the query command and the user option to get a list of logged on users. You could then search for the username that interests you and see if the ACTIVE tag is in the STATE column. From there, you could invoke an .rdp file if the user is not logged on or send a warning dialog if the user is logged on.

It's homemade, but it should work.

Example from one of my Windows servers:

C:\Users\BigKahuna>query user
>BigKahuna          rdp-tcp#0           1  Active          .  3/26/2012 6:51
share|improve this answer
sounds like a possibility, though i've never done any remote scripting and would have to learn it – Trent Apr 26 '12 at 17:07
@Trent It's the only way to get this done, and it's not such a huge deal. Look into WinRM and PowerShell Remoting. It's just a simple matter of running a few commands, storing a few things in variables and an if statement or two. – Wesley Apr 26 '12 at 19:42
Actually since "query user" is just a dos command, any programming language could execute and parse it. We have a web server running on the machine, so I think I will just write a browser-accessible perl or php script to do it. Should be a 1-liner. Thanks – Trent Apr 27 '12 at 17:25
@Trent Awesome! Hope it works out. – Wesley Apr 27 '12 at 17:32

This vbs script can be used to avoid kicking out someone already logged into a windows server under the same username:

Set objShell = WScript.CreateObject("WScript.Shell")
Set p = objShell.Exec("qwinsta /server:serverName")
Do While p.Status = 0
    WScript.Sleep 100
If InStr(p.StdOut.ReadAll, "Active") <= 0 then objShell.Run("mstsc C:\Users\username\Documents\Default.rdp")

It really just checks if there is any active user at all, but knowing your user name you could modify the last line to check specifically for it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.