Skip to content

Instantly share code, notes, and snippets.

@fredrikhaglund
Created June 20, 2014 23:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fredrikhaglund/43aea7522f9e844d3e7b to your computer and use it in GitHub Desktop.
Save fredrikhaglund/43aea7522f9e844d3e7b to your computer and use it in GitHub Desktop.
Launch Chrome from C#
internal static class ChromeLauncher
{
private const string ChromeAppKey = @"\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
private static string ChromeAppFileName
{
get
{
return (string) (Registry.GetValue("HKEY_LOCAL_MACHINE" + ChromeAppKey, "", null) ??
Registry.GetValue("HKEY_CURRENT_USER" + ChromeAppKey, "", null));
}
}
public static void OpenLink(string url)
{
string chromeAppFileName = ChromeAppFileName;
if (string.IsNullOrEmpty(chromeAppFileName))
{
throw new Exception("Could not find chrome.exe!");
}
Process.Start(chromeAppFileName, url);
}
}
@fredrikhaglund
Copy link
Author

@jogibanger
Copy link

HI Fredrikhaglund,
can you some help .. I want google chrome in my windows application

@lin-zy1229
Copy link

Great~!!!

@shhhidan
Copy link

shhhidan commented Mar 28, 2017

Why don't you want to use single one line
Process.Start("chrome.exe", url);
instead?

@Sasino97
Copy link

Why don't you want to use single one line
Process.Start("chrome.exe", url);
instead?

Because that requires the Chrome folder being in the PATH environment variable

@reyou
Copy link

reyou commented Jun 19, 2019

Works great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment