Background: I need a windows service to recognize a given condition (Which is working so i'll leave that out), kill a process (that section I have working and won't go into detail with either), and then restart that process.
This process needs to be started by this windows service, which runs as LocalSystem, but needs to be started as a user, and the application needs to appear in that user's session so that they may continue to interact with it.
The credentials are stored, encrypted, in text files, and are then read by the Windows service and used with a process.Start command to start the application after killing it.
The following code works if run via a Windows Forms app I'd used to configure some data as well as test this functionality, but not when it's run by the Windows Service running as LocalSystem.
System.Diagnostics.Process.Start("C:\Program Files (x86)\(app folder)\(applicationname).exe", username, SecurePassword, Domain)
When the service attempts to run this code, it throws an exception (Access Is Denied); This in turn is logged by my application to the Event log using a try/catch statement.
I've verified that it is using the correct user/pass/domain; It would give me a separate error if I were using the wrong credentials.
After a few hours of research, I found a complete answer with actual code example.
The end result allows the service to start the application under the currently logged in user, without even storing credentials.