From 8f00d8c5475b8cc05753f649a6370d8e1490b9c2 Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Mon, 31 Aug 2026 13:17:46 -0500 Subject: [PATCH] Find Edge and Chrome where they actually install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/install-extension-policy.ps1 | 36 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/scripts/install-extension-policy.ps1 b/scripts/install-extension-policy.ps1 index 6137c69..a8b9023 100644 --- a/scripts/install-extension-policy.ps1 +++ b/scripts/install-extension-policy.ps1 @@ -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) {