From 47c32536b0fe21f39e08d18915d668bca98ad3d2 Mon Sep 17 00:00:00 2001 From: Rune Darrud Date: Sun, 13 Mar 2016 23:13:01 +0100 Subject: [PATCH] Add uninstall to the chocolatey package refs #11369 --- icinga2.nuspec | 1 + tools/chocolateyUninstall.ps1 | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tools/chocolateyUninstall.ps1 diff --git a/icinga2.nuspec b/icinga2.nuspec index 831bb6693..110e3e5c2 100755 --- a/icinga2.nuspec +++ b/icinga2.nuspec @@ -22,5 +22,6 @@ + diff --git a/tools/chocolateyUninstall.ps1 b/tools/chocolateyUninstall.ps1 new file mode 100644 index 000000000..b9acd34dd --- /dev/null +++ b/tools/chocolateyUninstall.ps1 @@ -0,0 +1,25 @@ +$instDir = "unset" +$uninstaller = "Uninstall.exe" +$icingaRegistry64bitOS = "hklm:\SOFTWARE\Wow6432Node\Icinga Development Team\ICINGA2" +$icingaRegistry32bitOS = "hklm:\SOFTWARE\Icinga Development Team\ICINGA2" +$found = $false +$validExitCodes = @(0) + +if(test-path $icingaRegistry32bitOS) { + $instDir = (get-itemproperty -literalpath $icingaRegistry32bitOS).'(default)' + $found = $true +} +elseif(test-path $icingaRegistry64bitOS) { + $instDir = (get-itemproperty -literalpath $icingaRegistry64bitOS).'(default)' + $found = $true +} +else { + Write-Host "Did not find a path in the registry to the Icinga2 folder, did you use the installer?" +} + +if ($found) { + $packageArgs = "/S ?_=" + $statements = "& `"$instDir\$uninstaller`" $packageArgs`"$instDir`"" + + Start-ChocolateyProcessAsAdmin "$statements" -minimized -validExitCodes $validExitCodes +}