How to Open a Url in Chrome Incognito Mode

How to open a URL in chrome incognito mode

You'll need to create a process with a path to Chrome's exe file, and use the argument --incognito.

The path to chrome in windows is typically:


Use the following code:

var url = "";

using (var process = new Process())
process.StartInfo.FileName = @"C:\Users\<UserName>\AppData\Local\Google\Chrome\chrome.exe";
process.StartInfo.Arguments = url + " --incognito";


An article explaining this:

The full chrome command-line switch directory:

Opening chrome in incognito with a url

You are calling Process.Start twice:

  • The first one runs Chrome.exe with the parameter /incognito;
  • the second runs your URL, which Windows will launch with the default browser.

You need to launch Chrome.exe with two parameters: /incognito, and the url to open.

Chrome (and most other programs) accept parameters separated by spaces. So the format of your parameters should end up like /incognito

Therefore, try passing chrome a string consisting of param, a space, and then the URL, concatenated together with &:

Process.Start(chrome, param & " " & sURL)

Open a link in an Incognito Window in Google Chrome

To run any executable including Chrome in JAVA:

If the path to the application is a system variable:

String location = System.getenv("APPVARIAVLE");
Process process = new ProcessBuilder(location).start();

Or if you want to use the fully qualified path:

Process process = new ProcessBuilder("C:\\location\\MyApp.exe").start();

The JavaDoc for the process builder say that you can add parameters like this:

new ProcessBuilder("myCommand", "myArg1", "myArg2");

The argument for incognito looks like it is: "-incognito" and to open a url just add the url: "".

Which means that you can most likely can add the url and incognito arguments the following way to chrome in the arguments:

Process process = new ProcessBuilder("C:\\YourChrome\\Location\\chrome.exe","-incognito","").start();

Related Topics

Leave a reply