Open a new Google Chrome window with C #

Can I open a new instance from Chrome with C #?

In the instance, I mean a new separate tab that is not contained in the existing chrome window.

I tried the following solutions, but both of them create a new tab in the existing chromatic window or create an instance if no one exists:

Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "www.google.com"); Process.Start("chrome.exe", "www.google.com"); 

I always want to create a separate window, even if there are existing Chrome windows.

To be clear, in the end I want something like this (when I hovered over the chrome icon on the taskbar):

enter image description here

And not something like this:

enter image description here

I searched everywhere and I did not find a clear answer that tells me if this is possible or not with C #.

Thanks.

+7
source share
2 answers

You can do this by passing a --new-window argument to the process

 Process process = new Process(); process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; process.StartInfo.Arguments = "google.com" + " --new-window"; process.Start(); 
+10
source

The shortened version, first we look for Chrome, and then Firefox (the syntax is different)

 strURL="http://myurl.com"; try { //Launch Chrome in a new window System.Diagnostics.Process.Start("chrome", strURL+" --new-window"); } catch { try { //Chrome not found ... launch Firefox in a new window System.Diagnostics.Process.Start("firefox", "-new-window "+ strURL); } catch { //WARN THE USER TO INSTALL A BROWSER... } } 
0
source

Source: https://habr.com/ru/post/1260498/


All Articles