Skip to content

Instantly share code, notes, and snippets.

@delthas
Created October 16, 2017 23:47
Show Gist options
  • Save delthas/8bf2ff0415e59cb603cc9aaa170aa3b7 to your computer and use it in GitHub Desktop.
Save delthas/8bf2ff0415e59cb603cc9aaa170aa3b7 to your computer and use it in GitHub Desktop.
Keybase Chocolatey scripts
$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = 'https://prerelease.keybase.io/keybase_setup_386.exe'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
fileType = 'exe'
url = $url
softwareName = 'Keybase'
checksum = '3A88F750544F5EE22927C9230F7D1ACBE95124095E291FF04AC869279F044F7B'
checksumType = 'sha256'
silentArgs = "/install /quiet"
}
Install-ChocolateyPackage @packageArgs
$ErrorActionPreference = 'Stop'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
softwareName = 'Keybase'
fileType = 'exe'
silentArgs = "/uninstall /quiet"
}
[array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName']
if ($key.Count -eq 1) {
$key | % {
$packageArgs['file'] = "$($_.UninstallString)"
# Remove any parameters in the uninstaller path
$index = $packageArgs['file'].IndexOf("/")
if ($index -ne -1) {
$packageArgs['file'] = $packageArgs['file'].Substring(0, $index)
}
Uninstall-ChocolateyPackage @packageArgs
}
} elseif ($key.Count -eq 0) {
Write-Warning "$packageName has already been uninstalled by other means."
} elseif ($key.Count -gt 1) {
Write-Warning "$($key.Count) matches found!"
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
Write-Warning "Please alert package maintainer the following keys were matched:"
$key | % {Write-Warning "- $($_.DisplayName)"}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment