Hello guys
I have a Windows service which is checking for some changes in a database and when they happen it has to open Microsoft Project. As Microsoft Project is a UI application I need the service to be allowed to interact with the desktop (a user is always logged in) so it must run under the local system account.
I succeed to start a UI application from the service, e.g. Notepad but it runs under the local system account as well which is not enough for Microsoft Project. I made impersontion with the local administrator before starting the new process but it does not help - the new process still runs under the local system account.
I googled a lot and I found 4 different solutions, none of which works:
1. Use LogonUser and then CreateProcessAsUser to start the new process: I get an error 1314, ERROR_PRIVILEGE_NOT_HELD, even when I try this as a Windows application
2. Process.Start with user data: works fine as a Windows application but fails with error 5, "Access is denied" when run as a Windows service (I am testing it with Notepad.exe, everyone has access there, even the local system account can run it)
3. CreateProcessWithLogonW with user data: works fine as a Windows application but fails with error 5, "Access is denied" when run as a Windows service
4. I found a class called RunAs in Code Project which is based on CreateProcessWithLogonW as well and acts exactly the same
Does anyone have a good idea how this could work? I would appreciate any addition to the multiple articles I already found which point the problem but never show a solution.
TheAvenger
Start Free Trial