1

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.

2 Answers 2

3

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
2
  • Even if this doesn't do what the OP wants I think there is lots of win in looking at an approach like this. Mar 6, 2013 at 14:52
  • Actually this seems better, if I understand properly what it does. I will try this out. Mar 6, 2013 at 16:36
1

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.

2
  • 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. Mar 6, 2013 at 16:37
  • updated my answer
    – Chris S
    Mar 6, 2013 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .