Skip to content

Commit

Permalink
more robust uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmitheidw committed May 22, 2024
1 parent 45acdf6 commit a6831cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $packageArgs = @{
fileType = 'exe'
url = $url
softwareName = 'visualparadigm-ce*'
checksum = '1fc2209db6c3cd3b404bab530543a8ffae976f2b9426310de67745b4957c275c'
checksum = '1FC2209DB6C3CD3B404BAB530543A8FFAE976F2B9426310DE67745B4957C275C'
checksumType = 'sha256'
silentArgs = '-q -console'
validExitCodes= @(0, 3010, 1641)
Expand Down
53 changes: 30 additions & 23 deletions tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
$ErrorActionPreference = 'Stop';

[array]$key = Get-UninstallRegistryKey -SoftwareName 'visualparadigm-ce*'

$packageName='visualparadigm-ce'

if ($key.Count -eq 1) {

$key | ForEach-Object {
$packageArgs = @{
packageName = $packageName
fileType = 'EXE'
silentArgs = '-q'
validExitCodes = @(0)
file = "C:\Program Files\Visual Paradigm CE 17.1\uninstaller\uninstall.exe"
}
Uninstall-ChocolateyPackage @packageArgs
}

# Get all uninstall registry keys for visual paradigm
[array]$keys = Get-UninstallRegistryKey -SoftwareName 'visualparadigm-ce*'

$packageName = 'visualparadigm-ce'

if ($keys.Count -gt 0) {
$keys | ForEach-Object {
# Get the UninstallString from the registry key
$uninstallString = $_.UninstallString

# Validate if the executable path exists
if (Test-Path ($uninstallString -replace '"', '')) {
$packageArgs = @{
packageName = $packageName
fileType = 'EXE'
silentArgs = '-q'
validExitCodes = @(0)
file = $uninstallString
}

# Uninstall the package
Uninstall-ChocolateyPackage @packageArgs
} else {
Write-Warning "Uninstall executable not found at path: $uninstallString"
}

}
}
} else {
Write-Warning "No matches found for software name '$packageName'."
}
else {
Write-Warning "$key.Count matches found, aborting multiple copy uninstall!"

}



0 comments on commit a6831cf

Please sign in to comment.