$BadCode = '{0A0AC079-D00E-40CB-882B-1FED732786AA}' $GoodCode = '{A9CDEFA1-AB19-426F-8065-64331E634A62}' # never touch this one $DryRun = $true # set to $false to actually delete function ConvertTo-PackedGuid([string]$g) { $h = $g.Trim('{}').Replace('-', '') $rev = { param($s) -join ($s.ToCharArray()[($s.Length-1)..0]) } $swap = { param($s) -join (0..($s.Length/2-1) | ForEach-Object { $s[2*$_+1] + [string]$s[2*$_] }) } (& $rev $h.Substring(0,8)) + (& $rev $h.Substring(8,4)) + (& $rev $h.Substring(12,4)) + (& $swap $h.Substring(16,4)) + (& $swap $h.Substring(20,12)) } if ($BadCode -eq $GoodCode) { throw "Refusing: bad and good codes are identical." } $packed = ConvertTo-PackedGuid $BadCode Write-Host "Packed GUID: $packed" # should print 970CA0A0E00DBC0488B2F1DE377268AA # Step 1: try the supported removal first if (-not $DryRun) { $p = Start-Process msiexec -ArgumentList "/x $BadCode /qn /l*v C:\xcpng-bad-uninstall.log" -Wait -PassThru Write-Host "msiexec exit code: $($p.ExitCode)" if ($p.ExitCode -eq 0) { Write-Host "Removed cleanly."; return } } # Step 2: registry cleanup of only this product's keys $keys = @( "HKLM:\SOFTWARE\Classes\Installer\Products\$packed", "HKLM:\SOFTWARE\Classes\Installer\Features\$packed", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packed" ) $backupDir = "C:\msi-backup-$packed" New-Item -ItemType Directory -Path $backupDir -Force | Out-Null foreach ($k in $keys) { if (Test-Path $k) { $native = $k -replace '^HKLM:', 'HKLM' Write-Host "Found: $k" if (-not $DryRun) { $file = Join-Path $backupDir (($k -replace '[:\\]', '_') + '.reg') reg export $native $file /y | Out-Null Remove-Item -Path $k -Recurse -Force Write-Host " Backed up to $file and deleted." } } else { Write-Host "Not present: $k" } } if ($DryRun) { Write-Host "`nDry run only. Set `$DryRun = `$false to apply." }