-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uninstall old msi versions with different upgrade code
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | ||
} | ||
} | ||
} |