add Chocolatey package and uninstall scripts for iDescriptor

This commit is contained in:
uncore
2025-11-23 14:52:22 -07:00
parent ed0d8e64bd
commit 1051ac9df8
3 changed files with 81 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = 'https://github.com/iDescriptor/iDescriptor/releases/download/v0.1.0/iDescriptor-v0.1.0-Windows_x86_64.msi'
$checksum = 'bb803b3e4cfaa75068c28d15808284ad7d3400ed2bb7e98cdf1a2223d0543b6e'
$checksumType = 'sha256'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'msi'
url = $url
checksum = $checksum
checksumType = $checksumType
silentArgs = "/quiet /norestart"
validExitCodes = @(0, 3010, 1641)
}
Install-ChocolateyPackage @packageArgs
+38
View File
@@ -0,0 +1,38 @@
$ErrorActionPreference = 'Stop'
$displayNamePattern = 'iDescriptor*'
Write-Host "Searching for installed application: '$displayNamePattern'"
$registryKey = Get-ItemProperty -Path @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
) -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like $displayNamePattern } | Select-Object -First 1
if ($registryKey) {
$productCode = $registryKey.PSChildName
$foundName = $registryKey.DisplayName
Write-Host "Found: '$foundName' with Product Code: '$productCode'"
Write-Host "Calling msiexec directly to uninstall..."
# Build the arguments for msiexec.exe
$uninstallArgs = "/x `"$productCode`" /qn /norestart"
Write-Host "Running: msiexec.exe $uninstallArgs"
# Start the uninstaller process and wait for it to finish
$process = Start-Process "msiexec.exe" -ArgumentList $uninstallArgs -Wait -PassThru
$exitCode = $process.ExitCode
Write-Host "msiexec.exe finished with exit code: $exitCode"
# Check if the exit code indicates success (0) or that a reboot is required (3010)
$validExitCodes = @(0, 3010, 1641)
if ($validExitCodes -notcontains $exitCode) {
throw "Uninstallation failed with exit code $exitCode."
} else {
Write-Host "Uninstallation successful."
}
} else {
# If the key is not found, it might have been uninstalled already. Don't error.
Write-Warning "Could not find a product starting with '$displayNamePattern' in the registry. The application may have already been uninstalled."
}