Spawning a process from a service

  • Thread starter Thread starter Marianne
  • Start date Start date
M

Marianne

There is an application (which I don't have access to modify) that launches a desktop toolbar for the user that needs to stay active throughout their session. I've been tasked with writing a service (in c#) that checks whether this process is running and if not, then relaunch it. In taking a first try at it I've come across a couple issues:
a.. How do I detect whether there is anyone logged on or not? If no one is logged on there's no use checking whether this process is active
b.. How do I launch the app in the context of the currently logged on user? Obviously, I won't have access to their password so I just need to be able to spawn a process in the context of the active user's session on the system
Any help would be greatly appreciated. Thanks.

Marianne
 
I was able to use the Windowstation and Desktop API's via P/Invoke to answer the first question but the second question remains. If I know the the context of the currently logged on user what is the easiest way to launch a process as that user? Thanks.
There is an application (which I don't have access to modify) that launches a desktop toolbar for the user that needs to stay active throughout their session. I've been tasked with writing a service (in c#) that checks whether this process is running and if not, then relaunch it. In taking a first try at it I've come across a couple issues:
a.. How do I detect whether there is anyone logged on or not? If no one is logged on there's no use checking whether this process is active
b.. How do I launch the app in the context of the currently logged on user? Obviously, I won't have access to their password so I just need to be able to spawn a process in the context of the active user's session on the system
Any help would be greatly appreciated. Thanks.

Marianne
 
Back
Top