Skip to content

Instantly share code, notes, and snippets.

@dtgm
Last active June 20, 2016 23:04
Show Gist options
  • Save dtgm/cae2e0ea3db5c7493bc522f4f51f364f to your computer and use it in GitHub Desktop.
Save dtgm/cae2e0ea3db5c7493bc522f4f51f364f to your computer and use it in GitHub Desktop.
Add to nuspec:
--------------
<dependencies>
<dependency id="chocolatey-uninstall.extension" />
</dependencies>
Copy/replace chocolateyInstall.ps1 with text below:
--------------------------------------------------
$packageName = 'miranda-ng'
$fileType = 'exe'
$url = 'http://www.miranda-ng.org/distr/stable/miranda-ng-v0.95.5.exe'
$url64 = 'http://www.miranda-ng.org/distr/stable/miranda-ng-v0.95.5_x64.exe'
$silentArgs = '/verysilent'
[array]$key = Get-UninstallRegistryKey -SoftwareName "Miranda NG"
$installedVersion = $key.DisplayVersion
if ([version]$installedVersion -ge [version]$env:ChocolateyPackageVersion) {
Write-Host "$packageName $installedVersion is already installed."
} else {
Write-Verbose "Uninstalling previous version"
Uninstall-ChocolateyPackage $packageName $fileType $silentArgs ($key.UninstallString.Replace('"',''))
Install-ChocolateyPackage $packageName $fileType $url $url64 $silentArgs
}
add file chocolateyUninstall.ps1
--------------------------------
$packageName = 'miranda-ng'
$softwareName = "Miranda NG"
$installerType = 'exe'
$silentArgs = '/verysilent'
$validExitCodes = @(0)
[array]$key = Get-UninstallRegistryKey -SoftwareName $softwareName
$key | ForEach-Object {
  Uninstall-ChocolateyPackage -PackageName $packageName `
                              -FileType $installerType `
                              -SilentArgs $silentArgs `
                              -File $($_.UninstallString.Replace('"','')) `
                              -ValidExitCodes $validExitCodes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment