From 7ac0f7cdcd742cded141a2d0b08164ae853ed1a7 Mon Sep 17 00:00:00 2001 From: lili Date: Tue, 2 Apr 2019 13:10:40 +0200 Subject: ps1s added --- tools/chocolateyuninstall.ps1 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tools/chocolateyuninstall.ps1 (limited to 'tools/chocolateyuninstall.ps1') diff --git a/tools/chocolateyuninstall.ps1 b/tools/chocolateyuninstall.ps1 new file mode 100644 index 0000000..ccdebae --- /dev/null +++ b/tools/chocolateyuninstall.ps1 @@ -0,0 +1,36 @@ + + + +$ErrorActionPreference = 'Stop'; +$packageArgs = @{ + packageName = $env:ChocolateyPackageName + softwareName = 'xidel*' + fileType = 'exe' + silentArgs = "/qn /norestart" + validExitCodes= @(0, 3010, 1605, 1614, 1641) +} + +$uninstalled = $false +[array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName'] + +if ($key.Count -eq 1) { + $key | % { + $packageArgs['file'] = "$($_.UninstallString)" + if ($packageArgs['fileType'] -eq 'MSI') { + $packageArgs['silentArgs'] = "$($_.PSChildName) $($packageArgs['silentArgs'])" + + $packageArgs['file'] = '' + } + + Uninstall-ChocolateyZipPackage @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)"} +} + + -- cgit v1.2.3-54-g00ecf