mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-14 09:14:29 +02:00
parent
233f8ffb17
commit
55d4662286
@ -1,25 +1,28 @@
|
|||||||
$instDir = "unset"
|
$packageName = "Icinga 2";
|
||||||
$uninstaller = "Uninstall.exe"
|
$fileType = 'msi';
|
||||||
$icingaRegistry64bitOS = "hklm:\SOFTWARE\Wow6432Node\Icinga Development Team\ICINGA2"
|
$silentArgs = '/qr /norestart'
|
||||||
$icingaRegistry32bitOS = "hklm:\SOFTWARE\Icinga Development Team\ICINGA2"
|
|
||||||
$found = $false
|
|
||||||
$validExitCodes = @(0)
|
$validExitCodes = @(0)
|
||||||
|
|
||||||
if(test-path $icingaRegistry32bitOS) {
|
try {
|
||||||
$instDir = (get-itemproperty -literalpath $icingaRegistry32bitOS).'(default)'
|
$packageGuid = Get-ChildItem HKLM:\SOFTWARE\Classes\Installer\Products |
|
||||||
$found = $true
|
Get-ItemProperty -Name 'ProductName' |
|
||||||
}
|
? { $_.ProductName -like $packageName + "*"} |
|
||||||
elseif(test-path $icingaRegistry64bitOS) {
|
Select -ExpandProperty PSChildName -First 1
|
||||||
$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) {
|
$properties = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packageGuid\InstallProperties
|
||||||
$packageArgs = "/S ?_="
|
|
||||||
$statements = "& `"$instDir\$uninstaller`" $packageArgs`"$instDir`""
|
|
||||||
|
|
||||||
Start-ChocolateyProcessAsAdmin "$statements" -minimized -validExitCodes $validExitCodes
|
$file = $properties.LocalPackage
|
||||||
|
|
||||||
|
# Would like to use the following, but looks like there is a bug in this method when uninstalling MSI's
|
||||||
|
# Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes
|
||||||
|
|
||||||
|
# Use this instead
|
||||||
|
$msiArgs = "/x $file $silentArgs";
|
||||||
|
Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes
|
||||||
|
|
||||||
|
Write-ChocolateySuccess $package
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-ChocolateyFailure $package "$($_.Exception.Message)"
|
||||||
|
throw
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user