Skip to content

Commit

Permalink
Uninstall old msi versions with different upgrade code
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda authored and Syer10 committed Jan 22, 2025
1 parent 01a748c commit 5c7781e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/resources/msi/UninstallPreviousVersions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# uninstall previous versions that do not have the same update code via the product name

$productName = "Suwayomi Server"

# Get the product code of the specified product
$productInfo = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $productName }

$productCount = $productInfo.Count
Write-Output "Found $productCount installations"

# Uninstall the product
if ($productCount -gt 0) {

$productInfo | ForEach-Object {
$installedVersion = "$($_.Name) ($($_.IdentifyingNumber))"
Write-Output "Uninstalling version: $($installedVersion)"
$uninstallResult = $_.Uninstall()
if ($uninstallResult.ReturnValue -eq 0) {
Write-Output "Successfully uninstalled $($installedVersion)"
} else {
Write-Output "Failed to uninstall $($installedVersion)"
}
}
}

0 comments on commit 5c7781e

Please sign in to comment.