spotube/choco-struct/tools/chocolateyuninstall.ps1
2022-01-18 11:10:02 +06:00

25 lines
989 B
PowerShell

$ErrorActionPreference = 'Stop'; # stop on all errors
$packageArgs = @{
packageName = $env:ChocolateyPackageName
softwareName = 'spotube*'
fileType = 'exe'
validExitCodes= @(0, 3010, 1605, 1614, 1641)
silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' # Inno Setup
}
[array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName']
if ($key.Count -eq 1) {
$key | % {
$packageArgs['file'] = "$($_.UninstallString)" #NOTE: You may need to split this if it contains spaces, see below
Uninstall-ChocolateyPackage @packageArgs
}
} elseif ($key.Count -eq 0) {
Write-Warning "$packageName has already been uninstalled by other means."
} elseif ($key.Count -gt 1) {
Write-Warning "$($key.Count) matches found!"
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
Write-Warning "Please alert package maintainer the following keys were matched:"
$key | % {Write-Warning "- $($_.DisplayName)"}
}