Home > front end >  Launching a specific chrome profile in C#
Launching a specific chrome profile in C#

Time:12-02

I have 3 chrome profiles and I'm using C# WinForms 2022 to load each profile in a single panel in a WinForm. I know how to launch, for example, the private profile in a single panel, something like this

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

The above code works well. But now I'm trying to add two panels to the same form and load chrome profiles 2 and 3 into panels 2 and 3 respectively.
I'm using the following code for profile 3 but it doesn't do any good to me

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

or

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

I'm unable to load a specific profile in any panel except the private profile and the default one.

Could anyone tell me what is wrong with this code?

CodePudding user response:

below code is working i think you missed the space near to --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""";
  • Related