Introduce Beyond Compare Windows package metadata and scripts for winget. Adds input manifest (ee/maintained-apps/inputs/winget/beyond-compare.json) plus install and uninstall PowerShell scripts that handle Inno Setup silent install flags and registry-based uninstaller discovery. Updates outputs: registers the app in ee/maintained-apps/outputs/apps.json and adds a versioned output file with installer URL, sha256, and script refs (ee/maintained-apps/outputs/beyond-compare/windows.json).
84 lines
2.2 KiB
PowerShell
84 lines
2.2 KiB
PowerShell
# Locates Beyond Compare's Inno Setup uninstaller from the registry and runs it
|
|
# silently. Beyond Compare's DisplayName embeds the version, so match by prefix
|
|
# and require the Scooter Software publisher.
|
|
|
|
$softwareNameLike = "Beyond Compare*"
|
|
$publisherLike = "*Scooter Software*"
|
|
|
|
$paths = @(
|
|
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
|
|
)
|
|
|
|
$exitCode = 0
|
|
|
|
try {
|
|
|
|
[array]$uninstallKeys = Get-ChildItem `
|
|
-Path $paths `
|
|
-ErrorAction SilentlyContinue |
|
|
ForEach-Object { Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue }
|
|
|
|
$selected = $null
|
|
foreach ($key in $uninstallKeys) {
|
|
if ($key.DisplayName -and $key.DisplayName -like $softwareNameLike -and $key.Publisher -like $publisherLike) {
|
|
$selected = $key
|
|
break
|
|
}
|
|
}
|
|
|
|
if (-not $selected -or -not $selected.UninstallString) {
|
|
Write-Host "Uninstall entry not found for $softwareNameLike"
|
|
Exit 1
|
|
}
|
|
|
|
# Best-effort: stop the app so the uninstaller doesn't fail on locked files.
|
|
Stop-Process -Name "BCompare" -Force -ErrorAction SilentlyContinue
|
|
|
|
$uninstallCommand = $selected.UninstallString
|
|
|
|
# Split the uninstall string into exe + args. Handle both quoted and unquoted
|
|
# exe paths.
|
|
$exePath = ""
|
|
$existingArgs = ""
|
|
if ($uninstallCommand -match '^\s*"([^"]+)"\s*(.*)$') {
|
|
$exePath = $matches[1]
|
|
$existingArgs = $matches[2].Trim()
|
|
} elseif ($uninstallCommand -match '^\s*(\S+)\s*(.*)$') {
|
|
$exePath = $matches[1]
|
|
$existingArgs = $matches[2].Trim()
|
|
} else {
|
|
Throw "Could not parse uninstall string: $uninstallCommand"
|
|
}
|
|
|
|
# Inno Setup silent uninstall flags.
|
|
foreach ($flag in @('/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART')) {
|
|
if ($existingArgs -notmatch [regex]::Escape($flag)) {
|
|
$existingArgs = ("$existingArgs $flag").Trim()
|
|
}
|
|
}
|
|
|
|
Write-Host "Uninstall command: $exePath"
|
|
Write-Host "Uninstall args: $existingArgs"
|
|
|
|
$processOptions = @{
|
|
FilePath = $exePath
|
|
PassThru = $true
|
|
Wait = $true
|
|
}
|
|
|
|
if ($existingArgs -ne '') {
|
|
$processOptions.ArgumentList = $existingArgs
|
|
}
|
|
|
|
$process = Start-Process @processOptions
|
|
$exitCode = $process.ExitCode
|
|
Write-Host "Uninstall exit code: $exitCode"
|
|
|
|
Exit $exitCode
|
|
|
|
} catch {
|
|
Write-Host "Error: $_"
|
|
Exit 1
|
|
}
|