Batch - Default Browser?

前端 未结 8 1118
北荒
北荒 2021-02-12 16:09

Is there a way for using a batch file to find the default browser on my computer?

8条回答
  •  执笔经年
    2021-02-12 16:47

    This code will set the Environment variable browser to FirefoxURL which gives you a good indicator:

    @ECHO OFF
    REG QUERY HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice > browser.txt
    FOR /F "skip=2 tokens=*" %%G IN (browser.txt) DO ( SET browser=%%G )
    SET browser=%browser:~20%
    ECHO Is: %browser%
    

    It works by querying the registry to a text file then skipping the first two lines (useless for your purposes), then taking the text that starts at the 20th character of te remaining line. Which gives you FirefoxURL

提交回复
热议问题