13

How can I determine the Windows default browser (at the top of the start menu)?

I am using VB6 but can probably adapt other code no problem.

There are similar questions on Stack Overflow, but they seem to provide incorrect answers.

For instance the key HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\ lists both Internet Explorer and Firefox on my PC.

And getting the .html association fails for me as well, as HTML files are associated with IE but Firefox is my default browser.

Note that I don't want to actually open the browser, just get it's name.

Behrooz
  • 1,696
  • 2
  • 32
  • 54
soupagain
  • 1,123
  • 5
  • 16
  • 32
  • All the answers crawl undocumented registry keys. [Use the supported API function instead](https://stackoverflow.com/a/70050569/12597) – Ian Boyd Nov 20 '21 at 23:08

4 Answers4

15
  • When you click on a .html file, the browser that opens it is the one that has registered the .html extension.

  • When you open a http:// link (e.g. by typing it into the "Start->Run" box), the browser that opens is the one that has registered the HTTP protocol (although it's usually the same browser in both cases).

  • Whatever is displayed in Start Menu is not related to this.

HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\(Default) is the current user's handler for the HTTP protocol (which means "default browser"; NOTE: this is NOT the same thing as the .html default handler!).

However, it is possible to have a different browser at the top of Start Menu without changing the default. FYI, the browser executable name in Start menu is stored in HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default).

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
  • 6
    In Windows 10 the `HKCU\Software\Classes\http` (and `https`) key is empty. Default browser for opening http (i.e. via Run dialog box) is defined by the subkey from [Greg T's answer](https://stackoverflow.com/a/12444963/1951524). – Martin Schneider Jun 04 '19 at 08:51
  • that registry entry gives me firefox, but my default browser is chrome :( – Dee May 24 '20 at 23:44
14

Tested in Windows 7 x64: This is a two step process. The user's default browser is in key:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid

Common browser Key Name:

  • IE: IE.AssocFile.HTM
  • FireFox: FirefoxHTML
  • Chrome: ChromeHTML
  • Opera: Opera.HTML

Replace <KEY NAME> below with one of the values above to find the executable:

HKCR\<KEY NAME>\shell\open\command

Autohotkey script to display the default browser path and executable:

MsgBox % "Default browser: " Browser()

Browser()
{
    ; Find the Registry key name for the default browser
    RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid

    ; Find the executable command associated with the above Registry key
    RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command

    ; The above RegRead will return the path and executable name of the brower contained within qoutes and optional parameters
    ; We only want the text contained inside the first set of quotes which is the path and executable
    ; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
    StringGetPos, pos, BrowserFullCommand, ",,1

    ; Decrement by one for the StringMid to work correctly
    pos := --pos

    ; Extract and return the path and executable of the browser
    StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
    Return BrowserPathandEXE
} 
THelper
  • 15,333
  • 6
  • 64
  • 104
Greg T
  • 141
  • 1
  • 2
  • 1
    Any idea what the difference is between this and @Piskvor's answer? His answer seems to work on Windows 8.1 x64 (so assuming it works on Windows 7 too though maybe it's because it's an upgrade?) – gman Aug 06 '14 at 23:10
  • 1
    On Windows 10 this is the only working answer for me since the subkey from Piskvors's answer does not exist. If you change the default browser in the [Default apps dialog](https://support.microsoft.com/en-us/help/4028161/windows-10-change-default-programs), the `ProgId` value of `.html\UserChoice` and `.htm\UserChoice` subkeys are changed (maybe at other places as well). – Martin Schneider Jun 04 '19 at 08:45
1

Default browsers are usually set on a per user basis. Have you tried HKEY_CURRENT_USER instead? Shows up on mine under there correctly.

alimbada
  • 1,392
  • 1
  • 12
  • 27
0

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

you'll get something like

HKEY_CLASSES_ROOT\htmlfile\shell\open\command (Default) REG_SZ "C:\Program Files\Internet Explorer\iexplore.exe" %1

gmctec
  • 1
  • 2