1

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");
        }
    }
}
3

1 Answer 1

2

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);
                }
            }
Sign up to request clarification or add additional context in comments.

3 Comments

Chrome isn't necessary in HKLM. It can be in HKCU, since it can be installed for a single user instead of all users
@Cid, you are right, but I think we should try read both two base key locations to get the correct chrome installation path.
Yes, of course. Hopefully, this is in the same key : HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.