Run A Script When A User Is Logging To a Disconnected Sessio

March 5, 2012 at 23:32:57
Specs: Windows 2008 64bit
Hello,
I want to run a "logon" script whenever a user is logging remotly to a disconnected TS session.
I mean that I have a user who was logged to a remote server an while ago and went from his computer, so his session got disconnected (not logged off)
now the user came back to his computer and he want's to log back to his disconncted session,
how can I run a script that will work when the user is logging to his disconnected session (much like a logon script for new sessions, but for disconnected sessions)
thanks!!

See More: Run A Script When A User Is Logging To a Disconnected Sessio

Report •

#1
March 6, 2012 at 05:32:06
I don't think that's possible with group policy, but you can set the server to end the session when the user disconnects, or after a session has been disconnected for a specified amount of time. That would cause the normal logon scripts to run after the user connects again.

EDIT: If that's not good, you'd have to write a service that watches for SERVICE_CONTROL_SESSIONCHANGE. You'll then need to check to see if the user is connecting. If it is, use CreateProcessAsUser() to kick off your script, or have your process do the work of the script itself.

How To Ask Questions The Smart Way


Report •

#2
March 6, 2012 at 07:11:36
Hi Razor and thanks,

sadly, I need the sessions to stay open (disconnected or active) and I would prefer not to write something on the server side..

do you know by any change a solution from the client side maybe? we're using mostly normal windows clients (XP,7...)


Report •

#3
March 6, 2012 at 07:57:52
You can modify your client session to call a script, and have that script call your shell. (It's labeled something like, "run program on connection.") Keep in mind the user will be logged out as soon after the script and any spawned processes terminate. I haven't tested it, but I suspect this method always starts a new session regardless of the state of any disconnected session.

I'm not sure what you're doing, but it might be time to reevaluate how you're doing it.

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question