Files
Harrison RavazzoloandAllen Houchins 06b3176042 Windows FMA - Android Studio (#46505)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Android Studio support for Windows is now available, adding a Windows
app entry and a specific Windows release version (2025.3.4.7).
* Install/uninstall now run non-interactively and include improved
detection of existing installations and version checks for safe
upgrades.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/fleetdm/fleet/pull/46505?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Allen Houchins <allenhouchins@mac.com>
2026-05-29 20:38:38 -05:00

81 lines
2.5 KiB
PowerShell

$displayNameLike = "Android Studio*"
$publisher = "Google"
$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, 1223)
$uninstall = $null
foreach ($p in $paths) {
$items = Get-ItemProperty "$p\*" -ErrorAction SilentlyContinue | Where-Object {
$_.DisplayName -like $displayNameLike -and $_.Publisher -like "$publisher*"
}
if ($items) { $uninstall = $items | Select-Object -First 1; break }
}
if (-not $uninstall -or (-not $uninstall.UninstallString -and -not $uninstall.QuietUninstallString)) {
Write-Host "Uninstall entry not found"
Exit 0
}
Stop-Process -Name "studio64" -Force -ErrorAction SilentlyContinue
$uninstallCommand = if ($uninstall.QuietUninstallString) {
$uninstall.QuietUninstallString
} else {
$uninstall.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 '\b/S\b') {
$existingArgs = ("$existingArgs /S").Trim()
}
# Run the uninstaller synchronously from its install dir so /S applies and the
# script waits for completion. InstallLocation is the app dir; the uninstaller
# (uninstall.exe) sits there too.
if ($uninstall.InstallLocation -and ($existingArgs -notmatch '_\?=')) {
$installDir = $uninstall.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
}