C# 如何在 Chrome 隐身模式下打开 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11857123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open a URL in chrome incognito mode
提问by Tuyen Pham
I set Chrome as default brower. To open a URL in Chrome, I wrote:
我将 Chrome 设置为默认浏览器。为了在 Chrome 中打开一个 URL,我写道:
Process.Start("http://domain.com");
Is any way to open that URL in incognito mode by c# (nomarly press Ctrl + Shift + N)?
有什么方法可以通过 c# 以隐身模式打开该 URL(通常按 Ctrl + Shift + N)?
采纳答案by Dan
You'll need to create a process with a path to Chrome's exe file, and use the argument --incognito.
您需要创建一个带有 Chrome exe 文件路径的进程,并使用参数--incognito.
The path to chrome in windows is typically:
Windows 中 chrome 的路径通常是:
C:\Users\<UserName>\AppData\Local\Google\Chrome\chrome.exe
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/
一篇解释这个的文章: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/
完整的chrome命令行开关目录:http: //peter.sh/experiments/chromium-command-line-switches/
回答by Tuyen Pham
I wrote this and it successfull:
我写了这个,它成功了:
Process.Start(@"chrome.exe", "--incognito http://domain.com");
回答by AmirRoohi2000
The path to chrome.exe has changed, or at least i think there is a different between x32 and x64. C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
chrome.exe 的路径已更改,或者至少我认为 x32 和 x64 之间存在差异。C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
回答by derekantrican
For anyone using the Brave browser, the solution is very similar to Dan's answer, just with the brave.exe path (note that for Brave, the exe is not located in %LocalAppData%).
对于使用 Brave 浏览器的任何人,解决方案与 Dan 的答案非常相似,只是使用了 brave.exe 路径(请注意,对于 Brave,该 exe 不在 中%LocalAppData%)。
var url = "http://www.google.com";
using (var process = new Process())
{
process.StartInfo.FileName = @"C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe";
process.StartInfo.Arguments = url + " --incognito";
process.Start();
}

