【问题标题】:Launching a specific chrome profile in C#在 C# 中启动特定的 chrome 配置文件
【发布时间】:2022-01-06 01:49:54
【问题描述】:

我有 3 个 chrome 配置文件,我正在使用 C# WinForms 2022 将每个配置文件加载到 WinForm 的单个面板中。 例如,我知道如何在单个面板中启动私人配置文件,类似这样

var url = "https://google.com";
var process = new Process();
process.StartInfo = new ProcessStartInfo("chrome.exe");
process.StartInfo.Arguments = url + " --incognito";

上面的代码运行良好。但现在我正在尝试将两个面板添加到同一个表单中,并将 chrome 配置文件 2 和 3 分别加载到面板 2 和 3 中。
我将以下代码用于配置文件 3,但它对我没有任何好处

var url = "https://google.com";
var process = new Process();
process.StartInfo = new ProcessStartInfo("chrome.exe");
process.StartInfo.Arguments = url + @"--profile-directory =""Profile 3""";

process.StartInfo.Arguments = url + "--profile-directory=\"Profile3\"";

我无法在除私人配置文件和默认配置文件之外的任何面板中加载特定配置文件。

谁能告诉我这段代码有什么问题?

【问题讨论】:

    标签: c# google-chrome processstartinfo


    【解决方案1】:

    以下代码正在运行,我认为您错过了 --profile 附近的空间。

    var url = "https://google.com";
                var process = new Process();
                process.StartInfo = new ProcessStartInfo("chrome.exe");
                //process.StartInfo.Arguments = url + " --incognito";
                process.StartInfo.Arguments = url + @" --profile-directory=""Profile 2""";
    

    【讨论】:

    • 是的,它有效。非常感谢。这个空间让我发疯了!
    • @Stephan Bauer ,请快速查看this question,它也与这个问题有关。谢谢
    猜你喜欢
    • 2017-07-17
    • 1970-01-01
    • 2018-03-02
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-19
    相关资源
    最近更新 更多