List installed browsers

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

List installed browsers

Post by MigrationUser »

12 Jul 2013 14:56
npocmaka

A simple script that reads the registry and lists installed browsers:

Code: Select all

@echo off
START /W REGEDIT /E "%Temp%.\BROW.reg" HKEY_CURRENT_USER\Software\Classes

setlocal enableDelayedExpansion
for /f "tokens=4 delims=\" %%B in ('type %Temp%.\BROW.reg ^| findstr  /E  "HTML\shell]"') do (
 set "browser=%%B"
 echo !browser:~0,-4!
)
endlocal

del /Q /F "%Temp%.\BROW.reg"
It's from my answer in SO and the question looked interesting to me.

----------------------------

#2 13 Jul 2013 01:08
foxidrive

It reports Firefox in mine, but doesn't list MSIE.

The OP asked to list all browsers and also which one was default.

----------------------------

#3 13 Jul 2013 08:14
npocmaka

Yep,

Here's an improved version:

Code: Select all

@echo off
setlocal enableExtensions

echo.
echo.
echo INSTALLED BROWSERS
echo.
echo.

rem for 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet
set "bits=64"

rem for 32 bit systems
if not exist "%Temp%\BROW3.reg" (
  START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
  set "bits=32"
)

if "%bits%" equ "64" (
 for /f "tokens=6 delims=\" %%B in ('type "%Temp%\BROW3.reg"" ^| findstr /E "DefaultIcon]"') do (
   echo %%B
 )
)

if "%bits%" equ "32" (
  for /f "tokens=5 delims=\" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
   echo %%B
 )
)
del /Q /F "%Temp%\BROW3.reg"

echo.
echo.
echo DEFAULT BROWSER
echo.
echo.

START /W REGEDIT /E "%Temp%\BROW4.reg" HKEY_CURRENT_USER\Software\Classes\webcal


for /f "tokens=* delims==@\0," %%B in ('type "%Temp%\BROW4.reg" ^| findstr /E ",0\"^"') do (
  echo %%~nB
)

del /Q /F "%Temp%\BROW4.reg"
Last edited by npocmaka (13 Jul 2013 11:02)

----------------------------

#4 13 Jul 2013 11:22
foxidrive


In Windows 8 32 bit I get this:
"

INSTALLED BROWSERS

The syntax of the command is incorrect.
"

----------------------------

#5 13 Jul 2013 12:02
npocmaka


This registry key HKEY_CURRENT_USER\Software\Classes\webcal is not presented on all machines...(probably this gives the error)

The default browser value must be stored in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\HTTP\shell\open\command , but I'm not sure if it always returns the correct value.
I've tested this on VistaX64 and Windows XP Home Edition (X32) and works fine so far :

Code: Select all

@echo off
setlocal enableExtensions

echo.
echo.
echo INSTALLED BROWSERS
echo.
echo.

rem for 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet
set "bits=64"

rem for 32 bit systems
if not exist "%Temp%\BROW3.reg" (
  START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
  set "bits=32"
)

if "%bits%" equ "64" (
 for /f "tokens=6 delims=\" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
   echo %%B
 )
)

if "%bits%" equ "32" (
  for /f "tokens=5 delims=\" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
   echo %%B
 )
)
del /Q /F "%Temp%\BROW3.reg"

echo.
echo.
echo DEFAULT BROWSER
echo.
echo.

if "%bits%" equ "64" (
 START /W REGEDIT /E "%Temp%\BROW4.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\HTTP\shell\open\command
)
if "%bits%" equ "32" (
 START /W REGEDIT /E "%Temp%\BROW4.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Classes\HTTP\shell\open\command
)


setlocal enableDelayedExpansion
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW4.reg" ^| find "@"') do (
	set "default=%%B"
	set "default=!default:\\=\!"
	set "default=!default:~0,-1!"
	for %%D in ("!default!") do echo %%~nD
)
endlocal
del /Q /F "%Temp%\BROW4.reg"
pause
----------------------------

#6 13 Jul 2013 12:35
foxidrive


Just for feedback I get this now. I haven't examined the code.

"

INSTALLED BROWSERS

DefaultIcon]
DefaultIcon]
DefaultIcon]

DEFAULT BROWSER

The system cannot find the file specified.
Could Not Find C:\Users\ME\AppData\Local\Temp\BROW4.reg
"

----------------------------

#7 13 Jul 2013 13:47
npocmaka


Hey, thanks for the feedback smile

To see what happens I'll need to see your exported registry files.
it seems the me that the registry nodes are with one less on your system (?)
This (at least the part that lists the browsers) should work on your machine:

Code: Select all

@echo off
setlocal enableExtensions

echo.
echo.
echo INSTALLED BROWSERS
echo.
echo.

rem for 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet


rem for 32 bit systems
if not exist "%Temp%\BROW3.reg" START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet

setLocal enableDelayedExpansion
for /f "tokens=*" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
  set "browser=%%B"
  set "browser=!browser:\DefaultIcon]=!"
  for %%P in ("!browser!") do echo %%~nP
)
endlocal

del /Q /F "%Temp%\BROW3.reg"

echo.
echo.
echo DEFAULT BROWSER
echo.
echo.

START /W REGEDIT /E "%Temp%\BROW4.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\HTTP\shell\open\command
if not exist "%Temp%\BROW4.reg"  START /W REGEDIT /E "%Temp%\BROW4.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\HTTP\shell\open\command
if not exist "%Temp%\BROW4.reg"   START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Classes\HTTP\shell\open\command


setlocal enableDelayedExpansion
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW4.reg" ^| find "@"') do (
	set "default=%%B"
	set "default=!default:\\=\!"
	set "default=!default:~0,-1!"
	for %%D in ("!default!") do echo %%~nD
)
endlocal
del /Q /F "%Temp%\BROW4.reg"
pause
At the moment I can't propose anything about the default browser... (it must be somewhere in HKEY_LOCAL_MACHINE\SOFTWARE\Classes)

Last edited by npocmaka (14 Jul 2013 10:28)

----------------------------

#8 13 Jul 2013 14:52
foxidrive


Yes, it works to show my browsers.

"

INSTALLED BROWSERS

FIREFOX
IEXPLORE
Opera

DEFAULT BROWSER

The system cannot find the file specified.
Could Not Find C:\Users\ME\AppData\Local\Temp\BROW4.reg
"

Thanks

----------------------------

#9 13 Jul 2013 16:43
npocmaka


One more attempt.Now I'm reading HKEY_CLASSES_ROOT\http\shell where the definitions should be more general. I've also added a check for default .html viewer .It is again tested on XP and Vista:

Code: Select all

@echo off
setlocal enableExtensions
 
echo.
echo.
echo INSTALLED BROWSERS
echo.
echo.
 
rem :::::::::::::::::::::::::::::::::::::::::::::::::::::
rem :: exporting registry values for installed browsers
rem :::::::::::::::::::::::::::::::::::::::::::::::::::::
 
rem for 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet
rem for 32 bit systems
if not exist "%Temp%\BROW3.reg" START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
 
setLocal enableDelayedExpansion
for /f "tokens=*" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
 rem extracting browser name from icon path
  set "browser=%%B"
 rem removing \DefaultIcon] string
  set "browser=!browser:\DefaultIcon]=!"
 rem get the browser name
  for %%P in ("!browser!") do echo %%~nP
)
endLocal
 
echo.
echo.
echo EXECUTABLES PATHS
echo.
echo.
 
setLocal enableDelayedExpansion
for /f "tokens=* delims=@=" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /B "@" ^| findstr /E ".exe\\\",0\"^"') do (
  set "browser=%%~B"
  set "browser=!browser:\\=\!"
  echo !browser!
 
)
setLocal enableDelayedExpansion
for /f "tokens=* delims=@=" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /B "@" ^| findstr /E ".exe,0\"^"') do (
  set "browser=%%~B"
  set "browser=!browser:\\=\!"
  set "browser=!browser:,0=!"
  echo !browser!
 
)
endLocal
 
 
rem delete temp file
del /Q /F "%Temp%\BROW3.reg"
 
 
echo.
echo.
echo DEFAULT BROWSER
echo.
echo.
 
START /W REGEDIT /E "%Temp%\BROW5.reg" HKEY_CLASSES_ROOT\http\shell\open\command
setLocal enableDelayedExpansion
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW5.reg" ^| find "@"') do (
    set "default=%%B"
        rem removing double slashes
    set "default=!default:\\=\!"
        rem removing end slash
    set "default=!default:~0,-1!"
        rem get the name
    for %%D in ("!default!") do echo %%~nD
)
endLocal
del /Q /F "%Temp%\BROW5.reg"
 
echo.
echo.
echo DEFAULT .HTML VIEWER
echo.
echo.
 
START /W REGEDIT /E "%Temp%\BROW6.reg" HKEY_CLASSES_ROOT\htmlfile\shell\open\command
setLocal enableDelayedExpansion
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW6.reg" ^| find "@"') do (
    set "default=%%B"
    set "default=!default:\\=\!"
    set "default=!default:~0,-1!"
    for %%D in ("!default!") do echo %%~nD
)
endLocal
del /Q /F "%Temp%\BROW6.reg"
echo.
echo.
pause
Last edited by npocmaka (15 Jul 2013 07:40)

----------------------------

#10 13 Jul 2013 18:27
#11 14 Jul 2013 01:52
foxidrive


Thanks Giacomo for the info and link.

Your code is working for default browser and editor (I never edit html in IE - always my text editor) though the installed browser area is blank.

"

INSTALLED BROWSERS



DEFAULT BROWSER

firefox

DEFAULT .HTML VIEWER

iexplore

"

----------------------------

#12 14 Jul 2013 21:56
npocmaka


It's strange.I didn't change the part that lists installed browsers...
The default viewer is the program that opens the files with .html extension by default.It's not necessary to be for editing.
Post Reply