@echo off rem Get the full path to the browser rem Output from the REG command in XP differs from Vista/7. rem Detect the operating system and adjust the number of tokens to retrieve accordingly. for /F "tokens=2 delims=[]" %%A in ('ver') do ( if "%%A" LEQ "Version 5.1.2600" ( set _Tokens=4 ) else ( set _Tokens=3 ) ) rem Although the open command for the browser is kept in HKLM, a default browser choice other than Internet Explorer rem is kept in HKCU. Check for the existence of a key in HKCU. If this fails, fall back on the key in HKLM. set _DefaultBrowser= reg query "HKCU\Software\Clients\StartMenuInternet" /ve >NUL 2>NUL if errorlevel 1 (set _DefaultBrowser=HKLM\Software\Clients\StartMenuInternet) else (set _DefaultBrowser=HKCU\Software\Clients\StartMenuInternet) set _BrowserKey= for /F "tokens=%_Tokens%* eol=!" %%A in ('reg query "%_DefaultBrowser%" /ve') do ( if "%%B"=="" (set _BrowserKey=%%A) else (set _BrowserKey=%%A %%B) ) rem Once the default browser is known, obtain the path to the browser in HKLM. set _BrowserPath= set /a _DecTokens=%_Tokens%-1 for /F "tokens=%_DecTokens%*" %%A in ('reg query "HKLM\Software\Clients\StartMenuInternet\%_BrowserKey%\shell\open\command" /ve') do set _BrowserPath=%%B echo Default browser=%_BrowserPath% pause