Reputation: 76
How Do I open google chrome using c#?
It shows System.ComponentModel.Win32Exception: 'The system cannot find the file specified'
I'd triedProcess.Start("C:\\Program Files(x86)\\Google\\Chrome\\Application\\chrome.exe");
too, but it shows the same exception
using System;
using System.Diagnostics;
namespace tempTest
{
class Program
{
static void Main(string[] args)
{
Process.Start("chrome.exe");
}
}
}
Upvotes: 1
Views: 663
Reputation: 319
The chrome application path can be read from the registry. You can try following codes:
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe", false);
if(key != null)
{
var path = Path.Combine(key.GetValue("Path").ToString(), "chrome.exe");
if(File.Exists(path))
{
Process.Start(path);
}
}
Upvotes: 2