Batch - Default Browser?

前端 未结 8 1105
北荒
北荒 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:27

    Thank you, @Rob.

    @Rob's answer is close, but it still only pulls the ProgId. This one will set the browser name as reported by the ProgId (not always what you expect) in the browser variable, the specific verb used as browserverb, and the cmd path as browsercmd:

    setlocal enableDelayedExpansion
    :: parse the ProgId
    FOR /F "usebackq tokens=1,2,* delims==" %%A IN (`REG QUERY "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" /v ProgId 2^>NUL ^| more +2`) DO (
        SET browserstub=%%C
        :: parse for Class information
        FOR /F "usebackq tokens=1,2,* delims==" %%R IN (`REG QUERY "HKCR\!browserstub!" /v AppUserModelId 2^>NUL`) DO SET "browser=%%T"
        FOR /F "usebackq tokens=1,2,* delims==" %%R IN (`REG QUERY "HKCR\!browserstub!\shell" /ve 2^>NUL`) DO SET "browserverb=%%T"
        FOR /F "usebackq tokens=1,2,* delims==" %%R IN (`REG QUERY "HKCR\!browserstub!\shell\!browserverb!\command" /ve 2^>NUL`) DO SET "browsercmd=%%T"
    )
    :: display results
    SET browser
    

提交回复
热议问题