#Requires -Version 7.0 <# .SYNOPSIS 移除 install-explorer-menu.ps1 注册的 SceneMarshal 右键菜单。 .DESCRIPTION 清理范围: - 5 处位置上的 SceneMarshal 父菜单(级联)及旧版平级项 - 级联用的共享子菜单键 SceneMarshalMenu / SceneMarshalMenuBg - 兜底模式(-Flat)注册的 SceneMarshal- 平级项 .EXAMPLE .\uninstall-explorer-menu.ps1 #> [CmdletBinding()] param() $ErrorActionPreference = 'Stop' $shells = @( 'HKCU:\Software\Classes\Directory\shell', 'HKCU:\Software\Classes\Directory\Background\shell', 'HKCU:\Software\Classes\SystemFileAssociations\.mkv\shell', 'HKCU:\Software\Classes\SystemFileAssociations\.mp4\shell', 'HKCU:\Software\Classes\SystemFileAssociations\.avi\shell' ) $keyNames = @('SceneMarshal', 'SceneMarshalArchive') $removed = 0 foreach ($shell in $shells) { foreach ($name in $keyNames) { $key = Join-Path $shell $name if (Test-Path -LiteralPath $key) { Remove-Item -LiteralPath $key -Recurse -Force $removed++ Write-Host " - 已移除 $key" -ForegroundColor DarkGray } } # 兜底模式留下的平级项 Get-ChildItem -LiteralPath $shell -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -like 'SceneMarshal-*' } | ForEach-Object { Remove-Item -LiteralPath $_.PSPath -Recurse -Force $script:removed++ Write-Host (" - 已移除 {0}" -f $_.PSChildName) -ForegroundColor DarkGray } } # 共享子菜单 foreach ($sub in @('SceneMarshalMenu', 'SceneMarshalMenuBg')) { $key = "HKCU:\Software\Classes\$sub" if (Test-Path -LiteralPath $key) { Remove-Item -LiteralPath $key -Recurse -Force $script:removed++ Write-Host " - 已移除 $key" -ForegroundColor DarkGray } } Write-Host ("✔ 右键菜单已清理({0} 项)" -f $removed) -ForegroundColor Green