r/PowerShell • • Dec 28 '25

Toggle Windows 11 Context menu

This script will toggle your default context menu in Windows 11 (Switch between the Win 11 and the "show more options" as default when you right click in Windows Explorer)

https://github.com/volshebork/PowerShell/blob/main/Context%20Menu/Toggle-ContextMenu.ps1

I am much more of a bash guy and I think too many comments is better than two few. I come from Linux, so I am not sure if there are any ps best practices I am missing. Hope this helps someone, because I know it is a game changer for me.

14 Upvotes

12 comments sorted by

View all comments

2

u/dbsmith Dec 29 '25

Oh cool! I have been maintaining mine since 2023. It uses native PowerShell for more of the actions and defaults to disabling the new context menu.


<# Set-NewContextMenu.ps1

    .SYNOPSIS
    Enables the classic context menu in Windows 11 so you don't always have to click "Show more options"

    .LINK
    https://www.pcgamer.com/windows-11-context-menu-fix-right-click/
#>

[CmdletBinding()]
param (
    [ValidateSet("Enabled", "Disabled")]
    [string]
    $NewContextMenu = "Disabled"
)

$hkcuKey = "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}"
$hkcuKeyInProc = "$hkcuKey\InProcServer32"

switch ($NewContextMenu) {
    Disabled {
        if (-not (Test-Path -Path $hkcuKeyInProc -Verbose)) {
            Write-Output "Disabling the new context menu . . ."
            New-Item -Path $hkcuKeyInProc -Force -Verbose -Value "" # Must set the key's (Default) value to blank instead of (value not set)
            Write-Output "Restarting explorer.exe . . ."
            Get-Process | Where-Object -Property ProcessName -EQ explorer | Stop-Process -Force -Verbose
            Start-Process -FilePath $env:windir\explorer.exe -Verbose
        }
    }
    Enabled {
        Write-Output "Key: $hkcuKey"
        if (Test-Path -Path $hkcuKey -Verbose) {
            Write-Output "Enabling the new context menu . . ."
            Remove-Item -Path $hkcuKey -Recurse -Force -Verbose
            Write-Output "Restarting explorer.exe . . ."
            Get-Process | Where-Object -Property ProcessName -EQ explorer | Stop-Process -Force -Verbose
            Start-Process -FilePath $env:windir\explorer.exe -Verbose
        }
    }
    Default {}
}