2024-03-28
508
15 MIN READ
@echo off
:: :::::: get default browser.exe path and run it :::::: ::
for /f "skip=2 tokens=3" %%a in ('reg query "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" /v ProgId') do (
set defaultBrowser=%%a
)
for /f "skip=2 tokens=3,*" %%b in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\%defaultBrowser%\Application" /v ApplicationIcon') do (
set browserPath="%%b %%c"
)
for /f "tokens=1 delims=," %%m in (%browserPath%) do (
set browserPath=%%m
)
:: open URL
"%browserPath%" -inprivate "https://aiahk-d-magnum.aiaazure.biz/engine/#/rulebases"
'reg query "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" /v ProgId
这行查询命令查询结果如下:
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice
ProgId REG_SZ MSEdgeHTM
该结果有5行,有用的信息只是 MSEdgeHTM
,标识了默认系统浏览器的名称,我们需要提取这个信息。
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\%defaultBrowser%\Application" /v ApplicationIcon
这行查询就是去查询名称为 MSEdgeHTM
的浏览器 .exe
文件地址。