Checking the default browser manually is easy: run
START ms-settings:defaultapps
and take a look at the Web browser setting.
Or run
START http://?
to open the default browser with its default (home) page(s), and check.
The true challenge is to get the default browser without human interaction.
I have seen many techniques and registry keys mentioned on the web, but so far none was reliable.
They all keep telling me my default browser is Internet Explorer, and I can assure you it isn't!
Techniques using ASSOC
(which actually searches HKEY_CURRENT_USER\SOFTWARE\Classes\.html
) and using its result in FTYPE
(searches HKEY_CURRENT_USER\SOFTWARE\Classes\
with ASSOC
result appended, e.g. HKEY_CURRENT_USER\SOFTWARE\Classes\htmlfile
) did work back in the Windows XP and 7 era, but they no longer do in Windows 10.
Joe Caverly and Steve Robertson provided me with the "new" registry value locations:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\ProgID
for local HTML files, and
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice\ProgID
for http(s) URLs.
This will return values like FirefoxHTML-308046B0AF4A39CB
.
To get the executable path, look in HKEY_CLASSES_ROOT
, e.g. HKEY_CLASSES_ROOT\FirefoxHTML-308046B0AF4A39CB\shell\open\command
which will return the path to the default browser's executable, e.g. "C:\Program Files\Mozilla Firefox\firefox.exe"
.
Note: | Unlike REG.EXE , PowerShell cannot read directly from HKEY_CLASSES_ROOT , it would require WMI to access that hive.However, a "copy" of HKEY_CLASSES_ROOT can be found in HKEY_LOCAL_MACHINE\SOFTWARE\Classes . |
See GetDefaultBrowser.bat for more details.
page last modified: 2023-03-22; loaded in 0.0021 seconds