CreateProcess for Currently Logged On User from Service running System Account?
Posted on 2004-03-24
The problem I am having is this:
There is a service that runs using the Local System Account, it needs to run in this context to prevent users from closing it. This service monitors an application that MUST always remain open, this application has to run as the currently logged on user. When I use CreateProcess from within the service to restart the application if it has been terminated by the user, CreateProcess runs the application within the Local System Account, this creates a problem since the application must run in the users account for reasons I wont go into here.
How do I use CreateProcess to launch an instance of specified application from the Currently Logged On users account. I do not want to enter username and password information by using LogOnUser because the currently logged on user is already authenticated I should not have to do this, also this is not an option since the user does not interact with this program. I believe what I will need to use is ImpersonateLoggedOnUser, and obtaining the current users process handle by using OpenProcessToken but after messing with this for nearly 2 weeks now I cannot figure out how to get this to work... Any help would be appreciated!!