views:

21

answers:

2

Suppose that you have an account which must always be running. (yes I know the answer is use a service, but at this time it's not possible - legacy stuff :)

that account has one or more critical applications which must always be running. if that account is unintentionally logged off, i'd like to have a service monitor it, and re-login the account.

Obviously the service would have know login/pwd of user - and it would be on the same machine.

Is there a way to do this ??

thanks for your help in advance, J_

A: 

Run your applications as service. There are some tools that can let you run applications as services.

this. __curious_geek
thanks for the response. I'd like to go that route, but the powers that be uh, aren't ready for that yet :)
J__
A: 

You can monitor the active sessions with WTSEnumerateSessions.

For each enumerated session you can call: WTSQuerySessionInformation passing in WTSUserName to get the primary username of that session that is logged in.

You can then use LogonUserEx to log the user in.

Brian R. Bondy
Thanks for the response good stuff! Question though, when using LogonUserEx(), once you use that, the user will stay logged in correct? and also any processes you start using the handle you get back from this function will stay running correct? thanks again.
J__
@J__: Yes that's correct.
Brian R. Bondy