# Uninstalls digiSeal reader. # # The setup registers an HKLM ARP entry (DisplayName "digiSeal reader") whose # UninstallString points at the shipped "uninstall digiSeal reader.exe". That # uninstaller supports a -silent switch for unattended removal. $softwareName = "digiSeal reader" $machineKey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' $machineKey32on64 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' $exitCode = $null try { [array]$uninstallKeys = Get-ChildItem ` -Path @($machineKey, $machineKey32on64) ` -ErrorAction SilentlyContinue | ForEach-Object { Get-ItemProperty $_.PSPath } foreach ($key in $uninstallKeys) { if ($key.DisplayName -eq $softwareName) { $raw = $key.QuietUninstallString if (-not $raw) { $raw = $key.UninstallString } if (-not $raw) { continue } # Parse into executable + args, handling quoted/unquoted/bare shapes. if ($raw -match '^\s*"([^"]+)"\s*(.*)$') { $exe = $matches[1]; $exeArgs = $matches[2].Trim() } elseif ($raw -match '(?i)^\s*(.+?\.exe)\s*(.*)$') { $exe = $matches[1]; $exeArgs = $matches[2].Trim() } else { $exe = $raw; $exeArgs = "" } if ($exeArgs -notmatch '(?i)-silent') { $exeArgs = "$exeArgs -silent".Trim() } Write-Host "Uninstall command: $exe" Write-Host "Uninstall args: $exeArgs" $process = Start-Process -FilePath $exe -ArgumentList $exeArgs -NoNewWindow -PassThru -Wait $exitCode = $process.ExitCode break } } } catch { Write-Host "Error: $_" Exit 1 } if ($null -eq $exitCode) { Write-Host "Uninstall entry not found for '$softwareName'." Exit 1 } Write-Host "Uninstall exit code: $exitCode" if ($exitCode -eq 3010 -or $exitCode -eq 1641) { Exit 0 } Exit $exitCode