How to open a URL in chrome incognito mode

2019-02-03 04:15发布

I set Chrome as default brower. To open a URL in Chrome, I wrote:

Process.Start("http://domain.com");

Is any way to open that URL in incognito mode by c# (nomarly press Ctrl + Shift + N)?

2条回答
爷的心禁止访问
2楼-- · 2019-02-03 04:44

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:

C:\Users\<UserName>\AppData\Local\Google\Chrome\chrome.exe

Use the following code:

var url = "http://www.google.com";

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

    process.Start();
}

An article explaining this: http://www.tech-recipes.com/rx/3479/google-chrome-use-a-command-line-switch-to-open-in-incognito-mode/

The full chrome command-line switch directory: http://peter.sh/experiments/chromium-command-line-switches/

查看更多
Viruses.
3楼-- · 2019-02-03 04:48

I wrote this and it successfull:

Process.Start(@"chrome.exe", "--incognito http://domain.com");
查看更多
登录 后发表回答