From c281bfb7f440d6ec92896713bb40870102ff622f Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 24 Dec 2014 19:07:31 +0000 Subject: [PATCH] (#201) Correcting uninstallation Rather than make a direct call to msiexec, use the Chocolatey Helper Method, which should handle waiting on the MSI to complete the uninstallation, and then carry on with writing Chocolatey success message. --- ChocolateyPackage/chocolateyUninstall.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ChocolateyPackage/chocolateyUninstall.ps1 b/ChocolateyPackage/chocolateyUninstall.ps1 index 9d41f1539..270663800 100644 --- a/ChocolateyPackage/chocolateyUninstall.ps1 +++ b/ChocolateyPackage/chocolateyUninstall.ps1 @@ -1,20 +1,23 @@ -$package = "ChocolateyGUI" +$packageName = "ChocolateyGUI"; +$fileType = 'msi'; +$silentArgs = '/qr /norestart' +$validExitCodes = @(0) try { $packageGuid = Get-ChildItem HKLM:\SOFTWARE\Classes\Installer\Products | Get-ItemProperty -Name 'ProductName' | - ? { $_.ProductName -like $package + "*"} | + ? { $_.ProductName -like $packageName + "*"} | Select -ExpandProperty PSChildName -First 1 $properties = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packageGuid\InstallProperties - $pkg = $properties.LocalPackage + $file = $properties.LocalPackage - msiexec.exe /x $pkg /qr /norestart + Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes Write-ChocolateySuccess $package } catch { Write-ChocolateyFailure $package "$($_.Exception.Message)" throw -} \ No newline at end of file +}