fleet/pkg/file/scripts/uninstall_msi_with_upgrade_code.ps1
Allen Houchins 10d9bccfc1
Add waits + norestart to MSI uninstall scripts (#31078)
Closes #31077.

- Added logic to wait for the uninstall command to finish running before
exiting the script.
- Also added the `/norestart` flag so users who click uninstall in
self-service aren't at risk of a sudden and unintentional reboot as the
result of software uninstalling.


# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

---------

Co-authored-by: Ian Littman <iansltx@gmail.com>
2025-07-23 09:27:59 -05:00

14 lines
No EOL
573 B
PowerShell

# Fleet uninstalls app by finding all related product codes for the specified upgrade code
$inst = New-Object -ComObject "WindowsInstaller.Installer"
foreach ($product_code in $inst.RelatedProducts("$UPGRADE_CODE")) {
$process = Start-Process msiexec -ArgumentList @("/quiet", "/x", $product_code, "/norestart") -Wait -PassThru
# If the uninstall failed, bail
if ($process.ExitCode -ne 0) {
Write-Output "Uninstall for $($product_code) exited $($process.ExitCode)"
Exit $process.ExitCode
}
}
# All uninstalls succeeded; exit success
Exit 0