I have a Windows Forms application (C#, NET 3.5) installed using an MSI installer. In this application I have a button that when pressed opens a browser with a specific URL. I use
Process.Start(url);
to open the browser. This works fine when debugging, but after the installation it has less than optimal results. For example.
- If I install it with the Just Me options selected i opens my default browser (FF) with current settings.
- If I install it with the Everyone option, when I press the button it opens a version of IE with out any of my recent settings (proxy, toolbars displayed etc)
As far as I can tell this issue is caused by the user associated with the application when installing.
Taking into account that may users require proxies and personal browser settings and that the Just Me, Everyone choice should remain up to the user. What is the best course o action?
I tried calling Process.Start(url) with the current logged in user using
ProcessStartInfo.UserName = Environment.UserName
But it also requires a password and asking for credentials is not an option.
Do you have any other suggestions, am I using Process.Start() incorrectly, are there settings I need to make during installation, is there anything I missed?
UPDATE: Using Process Explorer as data_smith suggested I noticed the following:
- If I install the application for Everyone it will start under the NT AUTHORITY\SYSTEM user hence the unconfigured browser.
- If I install the application with Just Me selected it starts under the current user
Is there a way, without asking for credentials, to make the application start (at windows boot) under the current user even though it is installed for everyone?
UPDATE: Following a suggestion by data_smith to use ShellExecute and the suggestions here and here I was able to solve the problem and get the desired behavior.
The main issue was that when the installer finished the application was started with Process.Start(); This started the application as the NT AUTHORITY\SYSTEM user (the users installers run under) therefore all browsers opened by this application would also be under SYSTEM user. By using the suggestion from data_smith and the suggestions linked above I was able to start the process under the current user.
After the computer is rebooted the application starts under the correct user as this is configured through registry entries.