How to identify the browsers installed in the system

Using Java, how can I detect all browsers installed on the system?

+4
source share
3 answers

You can not.

You can open the page using the default browser on the system with Java 6 *, but you cannot list all the browsers installed on the system.

Of course, you can iterate over the Windows C:\Program Files\ or * nix /usr/local (or other dirs) folder to check browser names, but you may run into user privilege problems and you are never guaranteed to get all browsers, and this OS is not independent.

+5
source

Do not think that you can detect ALL browsers installed in the system, but you can check if any specific is installed in the registry

0
source

For windows, you can get this in the form from the registry:

Get this information from java.

1) create a browsers.bat batch file with the following script.

echo Browsers> browser.txt for / f "skip = 4 delims =" %% A in ('reg query "HKEY_LOCAL_MACHINE \ SOFTWARE \ Clients \ StartMenuInternet" 2 ^> nul') do (echo %% ~ nA 1 β†’ browser. txt) output

2) Call the batch file from java using the following command. The process p = Runtime.getRuntime (). Exec ("cmd / c start browsers.bat", null, new file ("C: \ Users \ batch-file-path"));

This will save all available browsers in the browsers.txt file.

0
source

Source: https://habr.com/ru/post/1312974/


All Articles