开发者

How to Detect browsers installed in a system

开发者 https://www.devze.com 2023-01-03 11:57 出处:网络
Using Java, how can I detect all of the browsers that are installed on a syste开发者_如何学JAVAm?You can\'t.

Using Java, how can I detect all of the browsers that are installed on a syste开发者_如何学JAVAm?


You can't.

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

Sure, you can iterate over Windows' C:\Program Files\ folder or *nix's /usr/local (or other dirs) to check for browser names, but you might run into user-privilege issues and you're never guaranteed to get all browsers, nor is this OS independent.

  • http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/


For windows you can get this in formation from registry:

To get this information from java.

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

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

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

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


Don't think you can detect ALL browsers installed on a system but you could check whether a specific one is installed by looking in the registry

0

精彩评论

暂无评论...
验证码 换一张
取 消