Skip to content

Commit

Permalink
(#201) Correcting uninstallation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gep13 committed Dec 24, 2014
1 parent f933edb commit c281bfb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ChocolateyPackage/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit c281bfb

Please sign in to comment.