fix(desktop-update): updater window opens in the Windows 11 25H2 default browser

Get-DefaultBrowserExe read only the legacy UserChoice ProgId, which Windows
11 25H2 Settings no longer updates, so the update hand-off fell back to the
WinForms card (or a stale browser) on machines whose real default is
Chrome/Edge. Read UserChoiceLatest\ProgId first, legacy UserChoice second.

Fixes #108051. Follows #108062 / #108064.

Co-authored-by: KoNit-K <konit.block@protonmail.com>
Co-authored-by: Konstantin Khlopkov <konstantin.khlopkov93@gmail.com>
This commit is contained in:
Teknium
2026-10-07 01:26:37 -07:00
parent 5419d869bb
commit d95d5bca1f

View File

@@ -226,16 +226,21 @@ function Get-UiHtmlPath {
}
function Get-DefaultBrowserExe {
# The OS default browser, read from the UserChoice ProgId that the
# Windows Settings app writes (https first, http as fallback). Only
# The OS default browser, read from the ProgId that the Windows Settings
# app writes (https first, http as fallback). Windows 11 25H2 writes only
# UserChoiceLatest\ProgId and leaves the legacy UserChoice key stale or
# without a value, so the newer key is read first. Only
# Chromium-family browsers (ChromeHTML / MSEdgeHTM) support the
# --app + --user-data-dir combo the shim relies on; any other
# default browser returns $null and degrades to the WinForms card.
$progId = $null
foreach ($proto in @("https", "http")) {
try {
$progId = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$proto\UserChoice" -Name ProgId -ErrorAction Stop).ProgId
} catch { continue }
foreach ($sub in @("UserChoiceLatest\ProgId", "UserChoice")) {
try {
$progId = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$proto\$sub" -Name ProgId -ErrorAction Stop).ProgId
} catch { continue }
if ($progId) { break }
}
if ($progId) { break }
}
if (-not $progId) { return $null }