Find Edge and Chrome where they actually install
Test-BrowserInstalled probed App Paths under HKLM:\SOFTWARE only. Edge and Chrome ship 32-bit installers, so on a 64-bit box their App Paths entries live under WOW6432Node and a 64-bit PowerShell never saw them — the browser was skipped, silently, and -Browser All configured nothing for it. Checks the install directories first now, with App Paths (both registry views) as a backstop, and prints which browsers it is configuring. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
a55ba1ccfc
commit
8f00d8c547
@@ -60,14 +60,33 @@ $exes = @{
|
||||
Edge = 'msedge.exe'
|
||||
Brave = 'brave.exe'
|
||||
}
|
||||
# Where each one actually lands. Edge and Chrome are 32-bit installers on a
|
||||
# 64-bit box, which is also why the registry probe below has to look inside
|
||||
# WOW6432Node: a 64-bit PowerShell reading HKLM:\SOFTWARE sees the 64-bit view
|
||||
# and misses everything a 32-bit installer wrote.
|
||||
$installPaths = @{
|
||||
Chrome = @("$env:ProgramFiles\Google\Chrome\Application\chrome.exe",
|
||||
"${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe",
|
||||
"$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe")
|
||||
Edge = @("${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe",
|
||||
"$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe")
|
||||
Brave = @("$env:ProgramFiles\BraveSoftware\Brave-Browser\Application\brave.exe",
|
||||
"${env:ProgramFiles(x86)}\BraveSoftware\Brave-Browser\Application\brave.exe",
|
||||
"$env:LOCALAPPDATA\BraveSoftware\Brave-Browser\Application\brave.exe")
|
||||
}
|
||||
|
||||
function Test-BrowserInstalled([string]$Name) {
|
||||
# App Paths is where every one of these registers itself, per-machine or
|
||||
# per-user depending on how it was installed.
|
||||
foreach ($hive in @('HKLM:', 'HKCU:')) {
|
||||
if (Test-Path "$hive\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$($exes[$Name])") {
|
||||
return $true
|
||||
}
|
||||
foreach ($exe in $installPaths[$Name]) {
|
||||
if ($exe -and (Test-Path $exe)) { return $true }
|
||||
}
|
||||
# App Paths as a backstop, for an install somewhere unusual.
|
||||
$keys = @(
|
||||
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$($exes[$Name])",
|
||||
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\$($exes[$Name])",
|
||||
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$($exes[$Name])"
|
||||
)
|
||||
foreach ($key in $keys) {
|
||||
if (Test-Path $key) { return $true }
|
||||
}
|
||||
return $false
|
||||
}
|
||||
@@ -89,9 +108,12 @@ $targets = if ($Browser -eq 'All') {
|
||||
}
|
||||
|
||||
if (-not $targets) {
|
||||
throw 'Found no Chrome, Edge or Brave installation. Name one with -Browser if it is installed somewhere unusual.'
|
||||
throw 'Found no Chrome, Edge or Brave installation. Name one with -Browser to configure it regardless of what this can see.'
|
||||
}
|
||||
|
||||
Write-Host "Configuring: $($targets -join ', ')"
|
||||
|
||||
|
||||
$entry = "$Id;$UpdateUrl"
|
||||
|
||||
foreach ($target in $targets) {
|
||||
|
||||
Reference in New Issue
Block a user