I am trying to open a URL in a new browser window. Specifically, a new browser window. The following code launches the URL in the default browser, but always opens the URL as a new tab in an existing browser window (if one exists). I want to launch the new tab in a new browser window, regardless of if one (or more) browser windows are already open.
This code launches the URL in WinUI 3 (in a new tab in an existing browser window), and appears to be the simplest:
Windows.System.Launcher.LaunchUriAsync(new Uri("http://google.com"));
This code does the same thing, and also works in WinUI 3 (credit to this answer here):
Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.FileName = "http://google.com";
myProcess.Start();
Please note that the following code does NOT work at all in WinUI 3:
System.Diagnostics.Process.Start("http://google.com");
EDIT: Additional Ruled-out Method
The following modification of Process.Start()
works in WinUI 3, but like the above methods only opens new tabs in existing browser windows, and thus is not a solution to the question above (also note that it forces using a specific browser, rather than the default browser):
Process.Start("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "http://google.com");