Last active
May 10, 2026 12:54
-
-
Save k0pernikus/2c46f4c9e4b6a8353683e3584a716afa to your computer and use it in GitHub Desktop.
Windows 11, boinc registry cleanup of orphaned installations remaining in "Add or remove programs"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [CmdletBinding()] | |
| param() | |
| $identity = [Security.Principal.WindowsIdentity]::GetCurrent() | |
| $principal = New-Object Security.Principal.WindowsPrincipal($identity) | |
| $adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator | |
| if (-not $principal.IsInRole($adminRole)) { | |
| Start-Process powershell.exe -ArgumentList "-NoExit -NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs | |
| exit | |
| } | |
| $hives = @( | |
| "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", | |
| "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*", | |
| "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", | |
| "HKLM:\SOFTWARE\Classes\Installer\Products\*" | |
| ) | |
| $found = @() | |
| foreach ($path in $hives) { | |
| $keys = Get-Item -Path $path -ErrorAction SilentlyContinue | |
| foreach ($key in $keys) { | |
| $props = Get-ItemProperty -Path $key.PSPath -ErrorAction SilentlyContinue | |
| $displayName = [string]$props.DisplayName | |
| $productName = [string]$props.ProductName | |
| $keyName = [string]$key.Name | |
| $installDir = [string]$props.InstallLocation | |
| $isMatch = ($displayName -match "BOINC") -or ($productName -match "BOINC") -or ($keyName -match "BOINC") | |
| if (-not $isMatch) { continue } | |
| $dirStatus = "Purged (Folder Missing)" | |
| if ([string]::IsNullOrWhiteSpace($installDir)) { | |
| $dirStatus = "Never Existed (No Path in Registry)" | |
| $installDir = "N/A" | |
| } | |
| $pathValid = $installDir -ne "N/A" -and (Test-Path $installDir) | |
| if ($pathValid) { $dirStatus = "Exists (Skipping)" } | |
| $found += [PSCustomObject]@{ | |
| EntryName = $displayName ? $displayName : ($productName ? $productName : $key.PSChildName) | |
| DirStatus = $dirStatus | |
| InstallDir = $installDir | |
| RegistryPath = $key.PSPath | |
| } | |
| } | |
| } | |
| $results = $found | Sort-Object RegistryPath -Unique | |
| if ($results.Count -eq 0) { | |
| Write-Output "No BOINC entries found." | |
| return | |
| } | |
| $skipped = $results | Where-Object { $_.DirStatus -eq "Exists (Skipping)" } | |
| if ($skipped.Count -gt 0) { | |
| Write-Output "`n--- SKIPPED (Installation Directory Still Exists) ---" | |
| $skipped | Format-Table EntryName, DirStatus, InstallDir, RegistryPath -AutoSize -Wrap | |
| } | |
| $orphaned = $results | Where-Object { $_.DirStatus -ne "Exists (Skipping)" } | |
| if ($orphaned.Count -eq 0) { | |
| Write-Output "`nNo orphaned entries available for removal." | |
| return | |
| } | |
| Write-Output "`n--- READY FOR REMOVAL ---" | |
| $orphaned | Format-Table EntryName, DirStatus, InstallDir, RegistryPath -AutoSize -Wrap | |
| $confirmation = Read-Host "Delete these $($orphaned.Count) orphaned registry entries? (Y/N)" | |
| if ($confirmation -notmatch "^[yY]$") { | |
| Write-Output "Operation cancelled." | |
| return | |
| } | |
| foreach ($item in $orphaned) { | |
| Remove-Item -Path $item.RegistryPath -Recurse -Force -ErrorAction SilentlyContinue | |
| Write-Output "Removed: $($item.RegistryPath)" | |
| } | |
| Write-Output "Cleanup complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment