Process.Start does not work anymore

Skysmith 146 Reputation points
2023-02-06T19:26:26.12+00:00

I have a simple code that used to work, but it does not work anymore.

Process.Start("Some Website Address");

Also, the code below works:

Process.Start(@"C:\Program Files\Google\Chrome\Application\chrome.exe", "Some Website Address");

But, the following code does not work. (It also used to work.)

Process.Start(@"chrome.exe", "Some Website Address");

I recently upgraded the project to .NET 7 from .NET 5 using the upgrade-assistant.

The upgrade process did not have any errors and the application launches without any problems.

Any help would be greatly appreciated.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,262 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,096 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jack J Jun 24,276 Reputation points Microsoft Vendor
    2023-02-07T02:03:56.58+00:00

    @skysmith , Welcome to Microsoft Q&A, based on my test, I reproduced your problem. I also could not use the following code to open chrome with specific URL.

    Based on my further research, you could try the following code to open the website with another browser:

                Process process = new Process();
                process.StartInfo.UseShellExecute = true;
                process.StartInfo.FileName = "chrome";
                process.StartInfo.Arguments = "www.google.com";
                process.Start();
    
    

    Best Regards.

    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Castorix31 81,061 Reputation points
    2023-02-06T19:50:51.7433333+00:00

    Use ShellExecute, like :

                using (Process p = new Process())
                {               
                    p.StartInfo.FileName = "www.google.com";
                    p.StartInfo.UseShellExecute = true;
                    p.Start();
                }