Last active
September 11, 2015 07:15
MSI package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'Stop'; | |
$packageArgs = @{ | |
packageName = '[[PackageName]]' | |
unzipLocation = $toolsDir | |
fileType = 'MSI' | |
url = '[[Url]]' | |
url64bit = '[[Url64]]' # 64bit URL here or remove - if installer is both, use $url | |
silentArgs = "/qn /norestart" | |
validExitCodes= @(0, 3010, 1641) | |
# optional, highly recommended | |
softwareName = '[[PackageName]]*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique | |
checksum = '[[Checksum]]' | |
checksumType = '[[ChecksumType]]' #default is md5, can also be sha1 | |
checksum64 = '[[Checksum64]]' | |
checksumType64= '[[ChecksumType64]]' #default is checksumType | |
} | |
Install-ChocolateyPackage @packageArgs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'Stop'; | |
$packageName = '[[PackageName]]' | |
$softwareName = '[[PackageName]]*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique | |
$installerType = 'MSI' | |
$silentArgs = '/qn /norestart' | |
# https://msdn.microsoft.com/en-us/library/aa376931(v=vs.85).aspx | |
$validExitCodes = @(0, 3010, 1605, 1614, 1641) | |
$uninstalled = $false | |
$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | |
$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' | |
$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | |
Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) ` | |
-ErrorAction SilentlyContinue ` | |
| ? { $_.DisplayName -like "$softwareName" } ` | |
| Select -First 1 ` | |
| % { | |
$silentArgs = "$($_.PSChildName) $silentArgs" | |
$file = '' | |
Uninstall-ChocolateyPackage -PackageName $packageName ` | |
-FileType $installerType ` | |
-SilentArgs "$silentArgs" ` | |
-ValidExitCodes $validExitCodes ` | |
-File "$file" | |
$uninstalled = $true | |
} | |
if (!($uninstalled)) { | |
Write-Warning "$packageName has already been uninstalled by other means." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment