fleet/ee/maintained-apps/inputs/winget/scripts/gimp_uninstall.ps1
Allen Houchins 452f1e8b1f
Add GIMP as a Windows FMA (#40372)
This pull request adds Windows support for GIMP version 3.0.8-2 to the
maintained apps. It introduces new install and uninstall scripts,
updates the app metadata, and provides integration details for Fleet's
package management.

New GIMP Windows app integration:

* App metadata: Added `gimp.json` in the `winget` inputs directory,
specifying package details, installer type, architecture, and default
categories.
* App listing: Updated `apps.json` to include the new GIMP Windows entry
with platform, slug, unique identifier, and description.

Installer and uninstaller scripts:

* Install script: Added `gimp_install.ps1` for silent, machine-scope
installation using Inno Setup installer flags.
* Uninstall script: Added `gimp_uninstall.ps1` for silent removal,
including logic to locate the correct uninstaller and handle edge cases.

Fleet integration and versioning:

* App version definition: Created `gimp/windows.json` output file,
detailing version, installer URL, install/uninstall script references,
SHA256, and Fleet query for existence.
2026-02-23 21:28:09 -06:00

86 lines
2.7 KiB
PowerShell

# Fleet extracts name from installer (EXE) and saves it to PACKAGE_ID
# variable
$softwareName = "GIMP"
# It is recommended to use exact software name here if possible to avoid
# uninstalling unintended software.
$softwareNameLike = "GIMP 3*"
# Inno Setup installers require /VERYSILENT flag for silent uninstall
$uninstallArgs = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
$machineKey = `
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machineKey32on64 = `
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
$exitCode = 0
try {
[array]$uninstallKeys = Get-ChildItem `
-Path @($machineKey, $machineKey32on64) `
-ErrorAction SilentlyContinue |
ForEach-Object { Get-ItemProperty $_.PSPath }
$foundUninstaller = $false
foreach ($key in $uninstallKeys) {
if ($key.DisplayName -like $softwareNameLike) {
$foundUninstaller = $true
# Get the uninstall command. Some uninstallers do not include
# 'QuietUninstallString' and require a flag to run silently.
$uninstallCommand = if ($key.QuietUninstallString) {
$key.QuietUninstallString
} else {
$key.UninstallString
}
# The uninstall command may contain command and args, like:
# "C:\Program Files\Software\uninstall.exe" /SILENT
# Split the command and args
$splitArgs = $uninstallCommand.Split('"')
if ($splitArgs.Length -gt 1) {
if ($splitArgs.Length -eq 3) {
$uninstallArgs = "$( $splitArgs[2] ) $uninstallArgs".Trim()
} elseif ($splitArgs.Length -gt 3) {
Throw `
"Uninstall command contains multiple quoted strings. " +
"Please update the uninstall script.`n" +
"Uninstall command: $uninstallCommand"
}
$uninstallCommand = $splitArgs[1]
}
Write-Host "Uninstall command: $uninstallCommand"
Write-Host "Uninstall args: $uninstallArgs"
$processOptions = @{
FilePath = $uninstallCommand
PassThru = $true
Wait = $true
}
if ($uninstallArgs -ne '') {
$processOptions.ArgumentList = "$uninstallArgs"
}
# Start process and track exit code
$process = Start-Process @processOptions
$exitCode = $process.ExitCode
# Prints the exit code
Write-Host "Uninstall exit code: $exitCode"
# Exit the loop once the software is found and uninstalled.
break
}
}
if (-not $foundUninstaller) {
Write-Host "Uninstaller for '$softwareName' not found."
$exitCode = 1
}
} catch {
Write-Host "Error: $_"
$exitCode = 1
}
Exit $exitCode