From: Rune Darrud Date: Sun, 13 Mar 2016 22:13:01 +0000 (+0100) Subject: Add uninstall to the chocolatey package X-Git-Tag: v2.5.0~480 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47c32536b0fe21f39e08d18915d668bca98ad3d2;p=icinga2 Add uninstall to the chocolatey package refs #11369 --- 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 +}