Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a (very) fragile software suite running on a server in our datacenter that requires a user to be logged in, but freaks out and crashes if the user logs in twice (resource contentions, all sorts of issues)

Due to its fragile nature, certain processes break all the time, requiring our support guys to connect to the machine via RDP and restart stuff. They connect via the generic account that is running in the open session, and disconnect instead of logging off.

Problem is, sometimes they don't end up connecting to the disconnected session, but instead spawn a new session, and the server subsequently fails.

I am looking for a way to detect, upon connecting/ logging in, if there is another RDP session on the machine and warn the user so disaster can be averted.

I would dearly love to chuck this machine out of a high window, but replacing the software is not an option at this point.

UPDATE

In the end, I implemented both solutions. This works swimmingly.

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

One approach may be to run a logon script that connects them to the disconnected session instead of requiring some action on their part.

SETLOCAL
SET SESSIONNUMBER=-1
FOR /F "skip=1 tokens=3" %%i in ('query session %username% ^| find /v ">"') DO SET SESSIONNUMBER=%%i
IF {%SESSIONNUMBER%}=={-1} GOTO :EOF
tscon.exe %SESSIONNUMBER%
ENDLOCAL
logoff.exe
share|improve this answer
    
Even if this doesn't do what the OP wants I think there is lots of win in looking at an approach like this. –  Evan Anderson Mar 6 '13 at 14:52
    
Actually this seems better, if I understand properly what it does. I will try this out. –  Jeremy Holovacs Mar 6 '13 at 16:36
add comment

Create a Group Policy (domain or edit the local computer settings): Computer Configuration, Administrative Templates, Windows Components, Terminal Services, Restrict Terminal Services users to a single remote session setting, Enable.

This would force the user to the existing session; unless someone else is currently in the session (where is gets slightly more complicated, but you don't seem concerned about the possibility of two people connecting at the same time).

This isn't what you asked for, but prevents the problem instead of adding some crazy script.

share|improve this answer
    
What sort of effect will this have? Will it prevent login, or force the user to the active connection? Having the login prevented would be undesirable; as I said, the system is fragile and we often need to login and fix things. –  Jeremy Holovacs Mar 6 '13 at 16:37
    
updated my answer –  Chris S Mar 6 '13 at 17:16
add comment

Your Answer

 
discard

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.