1
0
mirror of https://github.com/r4sas/chocolatey-packages synced 2025-01-20 20:00:21 +00:00
chocolatey-packages/yggdrasil/tools/chocolateyuninstall.ps1
2020-03-10 02:35:00 +03:00

43 lines
1.5 KiB
PowerShell

$ErrorActionPreference = 'Stop'; # stop on all errors
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$confDir = "$([Environment]::GetFolderPath('CommonApplicationData'))\Yggdrasil"
$startMenuDir = "$([Environment]::GetFolderPath('CommonStartMenu'))\Programs\Yggdrasil"
$softwareName = 'Yggdrasil Network*'
# Remove package, it don't touch configs
Write-Host "Package is being uninstalled, but configs are preserved. You can still find them in '$confDir' directory"
[array]$key = Get-UninstallRegistryKey -SoftwareName $softwareName
if ($key.Count -eq 1) {
$file = "$($key.UninstallString)"
$silentArgs = "$($key.PSChildName) /quiet"
$file = ''
$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'msi'
silentArgs = $silentArgs
validExitCodes = @(0)
file = $file
}
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 the package maintainer that the following keys were matched:"
$key | ForEach-Object { Write-Warning "- $($_.DisplayName)" }
}
# Remove shims
Uninstall-BinFile "yggdrasil"
Uninstall-BinFile "yggdrasilctl"
# Remove shortcuts from Start Menu
Remove-Item $startMenuDir -Recurse