0utsidethebox

FileExts cleanup

Aug 31st, 2026
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $basePath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts"
  2.  
  3. # Get all extension subkeys (keys starting with a dot)
  4. $extensions = Get-ChildItem -Path $basePath | Where-Object { $_.PSChildName -like ".*" }
  5.  
  6. foreach ($ext in $extensions) {
  7.     $extPath = $ext.PsPath
  8.    
  9.     # 1. Clean up OpenWithProgids
  10.     $openWithProgidsPath = "$extPath\OpenWithProgids"
  11.     if (Test-Path $openWithProgidsPath) {
  12.         # Find any property names that contain 'nomacs'
  13.         $progIds = Get-ItemProperty -Path $openWithProgidsPath
  14.         $progIds.PSObject.Properties | Where-Object { $_.Name -like "*nomacs*" } | ForEach-Object {
  15.             Write-Host "Removing Progid parameter '$($_.Name)' from $openWithProgidsPath"
  16.             Remove-ItemProperty -Path $openWithProgidsPath -Name $_.Name -ErrorAction SilentlyContinue -WhatIf
  17.         }
  18.     }
  19.  
  20.     # 2. Clean up UserChoice
  21.     $userChoicePath = "$extPath\UserChoice"
  22.     if (Test-Path $userChoicePath) {
  23.         $userChoiceValues = Get-ItemProperty -Path $userChoicePath -ErrorAction SilentlyContinue
  24.        
  25.         # Check if the ProgId value matches your target
  26.         if ($userChoiceValues -and $userChoiceValues.ProgId  -match 'nomacs') {
  27.             Write-Host "Clearing ProgId and Hash values in $userChoicePath"
  28.            
  29.             # Delete the specific properties inside UserChoice
  30.             Remove-ItemProperty -Path $userChoicePath -Name "ProgId" -ErrorAction SilentlyContinue -WhatIf
  31.             Remove-ItemProperty -Path $userChoicePath -Name "Hash" -ErrorAction SilentlyContinue -WhatIf
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment