fleet/ee/maintained-apps/inputs/winget/scripts/steam_uninstall.ps1
Allen Houchins c5a11b1b77
Add Steam as a macOS and Windows FMA (#37383)
This pull request adds support for managing Steam as a maintained
application on both macOS (darwin) and Windows platforms. It introduces
new metadata, installation, and uninstallation scripts, and updates the
aggregated app catalog to include Steam for both platforms.

**Steam app integration:**

- Added metadata and configuration files for Steam on macOS and Windows,
including installation details, unique identifiers, and categorization.
[[1]](diffhunk://#diff-c281dce9b3fb0c07ee0240f023b10f04f90d714ede790faa62a0e6f140db35b2R1-R8)
[[2]](diffhunk://#diff-2f3d984248d056735d116afea075ebb59e8e209b4a35ecc35bc82c21f760ed7aR1-R12)
- Updated the main `apps.json` catalog to include Steam entries for both
platforms, complete with descriptions and platform-specific slugs.

**Installer and uninstaller scripts:**

- Added a PowerShell installation script for Windows that installs Steam
silently using the `/S` flag.
- Added a PowerShell uninstallation script for Windows that locates the
Steam uninstaller and removes it silently, handling both 32-bit and
64-bit registry locations.
- Added macOS shell scripts (referenced in the output) for installing
and uninstalling Steam, including logic to quit running processes and
clean up associated files.

**App version outputs:**

- Created output files for both `steam/darwin.json` and
`steam/windows.json`, specifying version information, detection queries,
installer URLs, script references, and default categories.
[[1]](diffhunk://#diff-12ddb40a8998c18e5806cefa53ded63d64144a101d2cab1dfbbe78093e8cddeaR1-R21)
[[2]](diffhunk://#diff-6a83a89e114cb2281eb5ee80b6f574a374304c1baa60b927c7e1096044814a55R1-R21)
2025-12-16 21:05:19 -06:00

99 lines
3 KiB
PowerShell

# Fleet extracts name from installer (EXE) and saves it to PACKAGE_ID
# variable
$softwareName = $PACKAGE_ID
# It is recommended to use exact software name here if possible to avoid
# uninstalling unintended software.
$softwareNameLike = "*Steam*"
# NSIS installers require /S flag for silent uninstall
$uninstallArgs = "/S"
$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 }
$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" /S
# Split the command and args
$splitArgs = $uninstallCommand.Split('"')
if ($splitArgs.Length -gt 1) {
if ($splitArgs.Length -eq 3) {
$existingArgs = $splitArgs[2].Trim()
# Append /S if not already present
if ($existingArgs -notmatch '\b/S\b') {
$uninstallArgs = "$existingArgs /S".Trim()
} else {
$uninstallArgs = $existingArgs
}
} elseif ($splitArgs.Length -gt 3) {
Throw `
"Uninstall command contains multiple quoted strings. " +
"Please update the uninstall script.`n" +
"Uninstall command: $uninstallCommand"
}
$uninstallCommand = $splitArgs[1]
} else {
# No quotes, check if /S is already in the command
if ($uninstallCommand -notmatch '\b/S\b') {
$uninstallArgs = "/S"
} else {
$uninstallArgs = ""
}
}
Write-Host "Uninstall command: $uninstallCommand"
Write-Host "Uninstall args: $uninstallArgs"
$processOptions = @{
FilePath = $uninstallCommand
PassThru = $true
Wait = $true
}
if ($uninstallArgs -ne '') {
$processOptions.ArgumentList = $uninstallArgs
}
$process = Start-Process @processOptions
$exitCode = $process.ExitCode
Write-Host "Uninstall exit code: $exitCode"
break
}
}
if (-not $foundUninstaller) {
Write-Host "Uninstall entry not found for $softwareNameLike"
Exit 0
}
Exit $exitCode
} catch {
Write-Host "Error: $_"
Exit 1
}