Files
Allen Houchins 591a86f17d Add multiple Windows FMAs (#46794)
Add Winget input manifests for multiple maintained apps (Amazon DCV
client/server, Dell Command Update, Dell Display Manager, Lenovo Dock
Manager, Microsoft Remote Help, Nessus Agent, Plantronics Hub, Power
Automate, PowerToys, and RStudio). Include corresponding
install/uninstall PowerShell helper scripts under
ee/maintained-apps/inputs/winget/scripts and add Windows output metadata
(versions, installer URLs, checksums, installer/uninstaller refs) under
ee/maintained-apps/outputs/*/windows.json. Also update
ee/maintained-apps/outputs/apps.json to reflect the new entries. These
additions enable automated install/uninstall and fleet management for
the new Winget-backed apps.
2026-06-04 09:39:13 -05:00

70 lines
2.4 KiB
PowerShell

$displayNameLike = "RStudio*"
$publisherLike = "Posit Software*"
$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'
)
$ExpectedExitCodes = @(0, 1641, 3010, 1223)
$entry = $null
foreach ($p in $paths) {
$items = Get-ItemProperty "$p\*" -ErrorAction SilentlyContinue | Where-Object {
$_.DisplayName -like $displayNameLike -and $_.Publisher -like $publisherLike
}
if ($items) { $entry = $items | Select-Object -First 1; break }
}
if (-not $entry -or (-not $entry.UninstallString -and -not $entry.QuietUninstallString)) {
Write-Host "Uninstall entry not found"
Exit 0
}
Stop-Process -Name "rstudio" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "rsession" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "Rgui" -Force -ErrorAction SilentlyContinue
$uninstallCommand = if ($entry.QuietUninstallString) { $entry.QuietUninstallString } else { $entry.UninstallString }
$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"
}
if ($existingArgs -notmatch '(?i)(^|\s)/S(\s|$)') { $existingArgs = ("$existingArgs /S").Trim() }
if ($entry.InstallLocation -and ($existingArgs -notmatch '_\?=')) {
$installDir = $entry.InstallLocation.TrimEnd('\')
$existingArgs = ("$existingArgs _?=`"$installDir`"").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"
if ($ExpectedExitCodes -contains $exitCode) { Exit 0 }
Exit $exitCode
} catch {
Write-Host "Error running uninstaller: $_"
Exit 1
}