Skip to content

Uninstall script

Tunisiano18 edited this page Oct 30, 2022 · 6 revisions

Use this kind of uninstaller if the script is required

$packageName      = $env:ChocolateyPackageName
$fileType 	  = 'exe'
$silentArgs 	  = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-'
$validExitCodes   = @(0)
$unPath 	  = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$unPathx86 	  = "HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

try {
  $osBitness = Get-ProcessorBits
  if ($osBitness -eq 64 -and ($unString=(Get-ItemProperty "$unpath\$packageName*" UninstallString).UninstallString)) {
  } elseif ($osBitness -eq 64) {
	  $unString=(Get-ItemProperty "$unPathx86\$packageName*" UninstallString).UninstallString 
  } else {
    $unString = (Get-ItemProperty "$unPath\$packageName*" UninstallString).UninstallString
  }
  Uninstall-ChocolateyPackage "$packageName" "$fileType" "$silentArgs" "$unString" -validExitCodes $validExitCodes
} catch {
  throw $_.Exception
}

Source : https://github.com/dtgm/chocolatey-packages/issues/132

Clone this wiki locally