12

It is possible to open a new instance of Chrome from C#?

By instance I mean a new separate tab, not contained in an existing chrome window.

I've tried the following solutions but both of them create a new tab in an existing chrome window or creates 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 want to create always a separate window, even if there are existing Chrome windows.

To be clear, at the end I want something like that (when I hover on the chrome icon in the taskbar):

enter image description here

And not something like that:

enter image description here

I've searched everywhere and I haven't found a clear answer that says me if this is even possible or not from C#.

Thank you.

2
  • Google chrome will always create new instance and puts everything under tabs. What's the issue here? Commented Nov 29, 2016 at 7:28
  • I updated your question to avoid confusion and disappointment for people looking for a way to actually create a completely new and separate browser instance. Commented Nov 29, 2016 at 7:40

2 Answers 2

20

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

x86

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(); 

x64

Process process = new Process(); process.StartInfo.FileName = @"C:\Program Files\Google\Chrome\Application\chrome.exe"; process.StartInfo.Arguments = "google.com" + " --new-window"; process.Start(); 
Sign up to request clarification or add additional context in comments.

2 Comments

Yep. Just adding this as a clarification: technically this is not really giving you a new "instance" because the window is still managed by the same Chrome parent process and runs in the same browser session (i.e. using the same profile). But it results in the behavior desired by the OP.
Is there a way to do this without hard-coding the path to Chrome?
6

Shorter version, looking first for chrome then for 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... } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.