mirror of
https://github.com/fleetdm/fleet
synced 2026-05-01 18:37:37 +00:00
This pull request adds support for managing the installation and uninstallation of 010 Editor (version 16.0.2, 64-bit) on Windows via Winget in the maintained apps system. It introduces metadata, install/uninstall scripts, and output definitions for this application, enabling automated deployment and inventory. **010 Editor integration:** * Added a new input definition for 010 Editor in `winget/010-editor.json`, specifying metadata, installer details, and script paths. * Implemented PowerShell scripts for silent installation (`010-editor_install.ps1`) and uninstallation (`010-editor_uninstall.ps1`) tailored for Inno Setup-based installers. [[1]](diffhunk://#diff-4d1e3101294ff5dcd9414cbbd5a470a1bd2942f5d4e8db5c25c9fe4098b815b3R1-R28) [[2]](diffhunk://#diff-2ec71055559f078b69fc8cd53d483fc7738f0dbe7af384dda9587ecd76aeed23R1-R91) **Output and inventory updates:** * Generated a new output file `windows.json` for 010 Editor, including version info, installation checks, installer URL, script references, and SHA256 hash. * Updated the main `apps.json` output to include 010 Editor as a Windows application, ensuring it appears in the maintained apps inventory.
92 lines
3 KiB
PowerShell
92 lines
3 KiB
PowerShell
# Fleet extracts name from installer (EXE) and saves it to PACKAGE_ID
|
|
# variable
|
|
# For 010 Editor, we match against DisplayName "010 Editor" which appears in registry
|
|
$softwareName = "010 Editor"
|
|
|
|
# It is recommended to use exact software name here if possible to avoid
|
|
# uninstalling unintended software.
|
|
$softwareNameLike = "*$softwareName*"
|
|
|
|
# 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 needed, add -notlike to the comparison to exclude certain similar
|
|
# software
|
|
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."
|
|
# Change exit code to 0 if you don't want to fail if uninstaller is not
|
|
# found. This could happen if program was already uninstalled.
|
|
$exitCode = 1
|
|
}
|
|
|
|
} catch {
|
|
Write-Host "Error: $_"
|
|
$exitCode = 1
|
|
}
|
|
|
|
Exit $exitCode
|
|
|