Is there a way for using a batch file to find the default browser on my computer?
I hope this helps someone. I needed to start the default browser with a html file.
@echo off
setlocal
rem setup a default browser in case we fail
set default_browser=C:\Program Files\Internet Explorer\iexplore.exe
rem look in the HKEY_CLASSES_ROOT\htmlfile\shell\open\command registry for the default browser
for /f "tokens=*" %%a in ('REG QUERY HKEY_CLASSES_ROOT\htmlfile\shell\open\command /ve ^| FIND /i "default"') do (
set input=%%a
)
setlocal enableDelayedExpansion
rem parse the input field looking for the second token
for /f tokens^=^2^ eol^=^"^ delims^=^" %%a in ("!input!") do set browser=%%a
setlocal disableDelayedExpansion
rem this may not be needed, check if reg returned a real file, if not unset browser
if not "%browser%" == "" if not exist "%browser%" set browser=
if "%browser%"=="" set browser=%default_browser%
"%browser%" index.html
endlocal