Add winget inputs, install/uninstall scripts, and outputs for PostgreSQL 15, 16 and 17. Each version includes a JSON input manifest, install/uninstall PowerShell scripts (EnterpriseDB/BitRock installer with --mode unattended and --unattendedmodeui none), and generated outputs (per-version windows.json refs and apps.json entries). Also add frontend SVG icon components and 2x PNG assets for each version to display in the UI.
73 lines
2.2 KiB
PowerShell
73 lines
2.2 KiB
PowerShell
$displayNameLike = "PostgreSQL 15*"
|
|
$publisher = "PostgreSQL Global Development Group"
|
|
|
|
$paths = @(
|
|
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKCU:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
|
|
)
|
|
|
|
$uninstall = $null
|
|
foreach ($p in $paths) {
|
|
$items = Get-ItemProperty "$p\*" -ErrorAction SilentlyContinue | Where-Object {
|
|
$_.DisplayName -like $displayNameLike -and $_.Publisher -like "$publisher*"
|
|
}
|
|
if ($items) { $uninstall = $items | Select-Object -First 1; break }
|
|
}
|
|
|
|
if (-not $uninstall -or (-not $uninstall.UninstallString -and -not $uninstall.QuietUninstallString)) {
|
|
Write-Host "Uninstall entry not found"
|
|
Exit 0
|
|
}
|
|
|
|
$uninstallCommand = if ($uninstall.QuietUninstallString) {
|
|
$uninstall.QuietUninstallString
|
|
} else {
|
|
$uninstall.UninstallString
|
|
}
|
|
|
|
# Registry uninstall strings come in three shapes; parse defensively. The EDB
|
|
# uninstaller (uninstall-postgresql.exe) lives under a path with spaces
|
|
# ("C:\Program Files\PostgreSQL\15\...") and is typically quoted.
|
|
$exePath = ""
|
|
$existingArgs = ""
|
|
if ($uninstallCommand -match '^\s*"([^"]+)"\s*(.*)$') {
|
|
$exePath = $matches[1]
|
|
$existingArgs = $matches[2].Trim()
|
|
} elseif ($uninstallCommand -match '(?i)^\s*(.+?\.exe)\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"
|
|
}
|
|
|
|
# BitRock uninstaller silent switch.
|
|
if ($existingArgs -notmatch '(?i)--mode\s+unattended') {
|
|
$existingArgs = ("$existingArgs --mode unattended").Trim()
|
|
}
|
|
|
|
Write-Host "Uninstall command: $exePath"
|
|
Write-Host "Uninstall args: $existingArgs"
|
|
|
|
try {
|
|
$processOptions = @{
|
|
FilePath = $exePath
|
|
ArgumentList = $existingArgs
|
|
NoNewWindow = $true
|
|
PassThru = $true
|
|
Wait = $true
|
|
}
|
|
|
|
$process = Start-Process @processOptions
|
|
$exitCode = $process.ExitCode
|
|
Write-Host "Uninstall exit code: $exitCode"
|
|
Exit $exitCode
|
|
} catch {
|
|
Write-Host "Error running uninstaller: $_"
|
|
Exit 1
|
|
}
|