fleet/ee/maintained-apps/inputs/winget/scripts/linear_uninstall.ps1
Allen Houchins 3d067afb47
Add Linear as a Windows FMA (#43521)
Add Windows support for Linear: new winget input
(ee/maintained-apps/inputs/winget/linear.json) with installer metadata
and category, plus install/uninstall PowerShell scripts. Add output
metadata (ee/maintained-apps/outputs/linear/windows.json) including a
version entry, installer URL, sha256 and script refs, and register the
app in apps.json. Update frontend icon component to reference a new PNG
and add the image asset.

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #43501
2026-04-14 09:57:23 -05:00

112 lines
2.5 KiB
PowerShell

# Attempts to locate Linear's uninstaller from registry and execute it silently
$displayName = "Linear"
$productCode = "e614e7b4-b4f2-531a-be3f-ebb7fc898755"
$paths = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
)
$uninstall = $null
foreach ($p in $paths) {
$codeCandidates = @(
"$p\$productCode",
"$p\{$productCode}"
)
foreach ($candidate in $codeCandidates) {
if (Test-Path $candidate) {
$uninstall = Get-ItemProperty -Path $candidate -ErrorAction SilentlyContinue
if ($uninstall) {
break
}
}
}
if ($uninstall) {
break
}
$items = Get-ItemProperty "$p\*" -ErrorAction SilentlyContinue | Where-Object {
$_.DisplayName -and ($_.DisplayName -eq $displayName -or $_.DisplayName -like "$displayName*")
}
if ($items) {
$uninstall = $items | Select-Object -First 1
break
}
}
if (-not $uninstall) {
Write-Host "Uninstall entry not found"
Exit 0
}
$uninstallString = if ($uninstall.QuietUninstallString) {
$uninstall.QuietUninstallString
}
else {
$uninstall.UninstallString
}
if (-not $uninstallString) {
Write-Host "Uninstall command not found"
Exit 0
}
# Stop the app before uninstalling.
Stop-Process -Name "Linear" -Force -ErrorAction SilentlyContinue
$exePath = ""
$arguments = ""
if ($uninstallString -match '^"([^"]+)"(.*)') {
$exePath = $matches[1]
$arguments = $matches[2].Trim()
}
elseif ($uninstallString -match '^([^\s]+)(.*)') {
$exePath = $matches[1]
$arguments = $matches[2].Trim()
}
else {
Write-Host "Error: Could not parse uninstall string: $uninstallString"
Exit 1
}
$argumentList = @()
if ($arguments -ne '') {
$argumentList += $arguments -split '\s+'
}
# NSIS uninstallers require /S for silent mode.
if ($argumentList -notcontains "/S" -and $arguments -notmatch '\b/S\b') {
$argumentList += "/S"
}
Write-Host "Uninstall executable: $exePath"
Write-Host "Uninstall arguments: $($argumentList -join ' ')"
try {
$processOptions = @{
FilePath = $exePath
NoNewWindow = $true
PassThru = $true
Wait = $true
}
if ($argumentList.Count -gt 0) {
$processOptions.ArgumentList = $argumentList
}
$process = Start-Process @processOptions
$exitCode = $process.ExitCode
Write-Host "Uninstall exit code: $exitCode"
Exit $exitCode
}
catch {
Write-Host "Error running uninstaller: $_"
Exit 1
}