Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $basePath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts"
- # Get all extension subkeys (keys starting with a dot)
- $extensions = Get-ChildItem -Path $basePath | Where-Object { $_.PSChildName -like ".*" }
- foreach ($ext in $extensions) {
- $extPath = $ext.PsPath
- # 1. Clean up OpenWithProgids
- $openWithProgidsPath = "$extPath\OpenWithProgids"
- if (Test-Path $openWithProgidsPath) {
- # Find any property names that contain 'nomacs'
- $progIds = Get-ItemProperty -Path $openWithProgidsPath
- $progIds.PSObject.Properties | Where-Object { $_.Name -like "*nomacs*" } | ForEach-Object {
- Write-Host "Removing Progid parameter '$($_.Name)' from $openWithProgidsPath"
- Remove-ItemProperty -Path $openWithProgidsPath -Name $_.Name -ErrorAction SilentlyContinue -WhatIf
- }
- }
- # 2. Clean up UserChoice
- $userChoicePath = "$extPath\UserChoice"
- if (Test-Path $userChoicePath) {
- $userChoiceValues = Get-ItemProperty -Path $userChoicePath -ErrorAction SilentlyContinue
- # Check if the ProgId value matches your target
- if ($userChoiceValues -and $userChoiceValues.ProgId -match 'nomacs') {
- Write-Host "Clearing ProgId and Hash values in $userChoicePath"
- # Delete the specific properties inside UserChoice
- Remove-ItemProperty -Path $userChoicePath -Name "ProgId" -ErrorAction SilentlyContinue -WhatIf
- Remove-ItemProperty -Path $userChoicePath -Name "Hash" -ErrorAction SilentlyContinue -WhatIf
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment