I have a Windows Forms application (C #, NET 3.5) installed using the MSI installer. In this application, I have a button that, when clicked, opens a browser with a specific URL. I use
Process.Start(url);
to open the browser. This works great when debugging, but after installation has less optimal results. For instance.
- If I installed it with the Just Me options selected, I will open my default browser (FF) with the current settings.
- If I install it using the "All" option, when I click the button it opens a version of IE without any of my last settings (proxies, toolbars, etc.)
As far as I can tell, this problem is caused by the user associated with the application during installation.
Whereas users may need proxies and personal browser settings, and Just Just, each user should remain with the user. What is the best course of action?
I tried calling Process.Start (url) with the current logged in user using
ProcessStartInfo.UserName = Environment.UserName
But this also requires a password and requesting credentials is not an option.
Do you have any other suggestions, I am using Process.Start () incorrectly, are there any settings that I need to make during installation, is there something I missed?
UPDATE: Using Process Explorer as a data_smith package, I noticed the following:
- If I install the application for Everyone, it will run under NT AUTHORITY \ SYSTEM, therefore, an unconfigured browser.
- If I install the application using Just Me, it will start in the current user
Is there a way, without asking for credentials, to run the application (when Windows starts) under the current user, even if it is installed for everyone?
UPDATE: Following the data_smith suggestion to use ShellExecute and the suggestions here and here I was able to solve the problem and get the desired behavior.
The main problem was that when the installation was completed, the program started with Process.Start (); This started the application as the NT AUTHORITY \ SYSTEM user (for users running users), so all browsers opened by this application will also be under the SYSTEM user. Using the sentence from data_smith and the above sentences, I was able to start the process under the current user.
After the computer restarts, the application starts under the correct user, as it is configured through registry entries.