Launch Chrome and Other Applications in C#

Hi Everyone,

Short post, I just wanted to put down into writing how I open Chrome windows and other applications in C# code. This is used by one of my startup programs which allowed me to open all my most used applications with ease 🙂

First I create a Process variables using the System.Diagnostics resource:

Process process = new Process();

I then point the process variables start info filename to the location of my Chrome executable:

process.StartInfo.FileName = @"C:\Path\To\Chrome.exe";

I then add my URL to the start info arguments:

process.StartInfo.Arguments = @"https://bbc.co.uk";

Then, if I want the link to open as a new window instead of onto an existing Chrome window I use:

process.StartInfo.Arguments += " --new-windows";

Finally, I start the process:

process.Start();

Here are some different scenarios:

Opening a URL in an existing Chrome window:

Process process = new Process();
process.StartInfo.FileName = @"C:\Path\To\Chrome.exe";
process.StartInfo.Arguments = @"https://bbc.co.uk" ;
process.Start()

Opening a URL in a new Chrome window:

Process process = new Process();
process.StartInfo.FileName = @"C:\Path\To\chrome.exe";
process.StartInfo.Arguments = @"https://bbc.co.uk";
process.StartInfo.Arguments += " --new-window";
process.Start();

Opening multiple URLs in a new Chrome window:

List<String> URLs = new List<String>(){
    "https://bbc.co.uk",
    "https://mharwood.uk",
    "https://youtube.com"
}

Process process = new Process();
process.StartInfo.FileName = @"C:\Path\To\chrome.exe";
foreach (string i in URLs)
{
    process.StartInfo.Arguments += i;
}
process.StartInfo.Arguments += " --new-window";
process.Start();

Opening different programs:

List<String> Programs = new List<String>(){
    @"C:\Path\To\First\Program.exe",
    @"C:\Path\To\Second\Program.exe",
    @"C:\Path\To\Third\Program.exe"
}

foreach(string i in Programs){
    Process.Start(i);
}

I hope this is useful information for someone. Enjoy!

Leave a Comment

Your email address will not be published. Required fields are marked *

email popup image
Mark Harwood
NEVER miss a blog post again! Subscribe for email notifications whenever a new post is live!
Subscribe
NEVER miss a blog post again! Subscribe for email notifications whenever a new post is live!
Fill Out This Form, And I Will Be In Touch Shortly
Contact form image
I'll Be In Touch Soon