4

Some files or folders in Windows have path variables (like %appdata%, %systemroot%, %userprofile%, etc). Is there anything similar to get the default browser?

For example, it could take the value C:\Program Files\Google\Chrome\Application\chrome.exe if Google Chrome is the default browser, C:\Program Files\Mozilla Firefox\firefox.exe if Firefox is the default browser, C:\Program Files\Internet Explorer\iexplore.exe if Internet Explorer is the default browser, etc and always have the same name no matter what.

2 Answers 2

6

You can use:

reg QUERY HKEY_CLASSES_ROOT\htmlfile\shell\open\command /ve

And you will get something like:

(Default)    REG_SZ    "C:\Program Files (x86)\Internet Explorer\iexplore.exe"

Then you can easily parse it.

7
  • How do I use this in for example the Run dialog? Aug 8, 2016 at 13:52
  • 1
    @DonaldDuck Just enter a URL in the "Run" box and it will open in your default browser, for example type http://www.google.com following by <enter>
    – DavidPostill
    Aug 8, 2016 at 14:38
  • 3
    The value of this registry key is "C:\Program Files\Internet Explorer\iexplore.exe" %1 but my default browser is Chrome. Sep 12, 2016 at 12:39
  • What OS are you using? Sep 12, 2016 at 17:43
  • 1
    This returns Internet Explorer no matter what the default browser is. To get the default browser, I've figured out that you need to go to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\ProgId, and then use that value in HKEY_CLASSES_ROOT\[value here]\shell\open\command. Oct 3, 2020 at 12:08
0

To get the info about the default browser, you need to check the Windows registry.

You can find more info about this here :

https://newoldthing.wordpress.com/2007/03/23/how-does-your-browsers-know-that-its-not-the-default-browser/

Also you might won to check this to. https://stackoverflow.com/questions/4222367/windows-registry-key-for-check-whether-ie-is-the-default-browser

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .