Disable Default "Open Windows PowerShell" Right-Click Menu?

Jonathan Woodward 31 Reputation points
2023-08-01T18:34:44.15+00:00

image

How would one permanently disable Shift+Right-Click "Open PowerShell window here" context menu without simultaneously disabling the PowerShell and Elevated PowerShell Options in the File Explorer File Menu Bar?

More info: For Registry Keys [HKLM\Software\Classes\Directory\shell\PowerShell], [HKLM\Software\Classes\DirectoryBackground\shell\PowerShell], and [HKLM\Software\Classes\Drive\shell\PowerShell] keys, the default Shift+Right-Click "Open with PowerShell window here" context menu can be disabled by adding "LegacyDisable" or "ProgrammaticAccessOnly" strings. Doing so, however, also disables (greys out) the PowerShell and Admin PowerShell Options in Explorer File Menu bar.

What would be the correct string or dword or any registry modification to disable the shift+right-click menu without disabling the Explorer File Menu bar options?

Would the keys above be the correct ones to modify? Perhaps a CLSID key or a key from the window command store? [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell]?

Thanks!

Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. S.Sengupta 24,476 Reputation points MVP
    2023-08-02T00:28:32.4666667+00:00

    Log in as Admin and Locate:

    HKEY_CLASSES_ROOT\Directory\shell\Powershell

    Right-click the "Powershell" key in the left pane and then select New -> String Value.

    Make a new string called "ProgrammaticAccessOnly" with no value data.

    You've now successfully deleted "Open PowerShell window here" from the context menu when you right-click any folder while holding SHIFT.

    1 person found this answer helpful.

  2. Weiqi Chen 101 Reputation points
    2025-05-07T06:24:57.6566667+00:00
    cd /d %~dp0
    subinacl /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Powershell /setowner=Administrators
    subinacl /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Powershell /grant=Administrators=f
    
    subinacl /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell /setowner=Administrators
    subinacl /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell /grant=Administrators=f
    
    subinacl /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\Powershell  /setowner=Administrators
    subinacl /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\Powershell  /grant=Administrators=f
    
    
    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Powershell /v "ProgrammaticAccessOnly" /t REG_SZ /d "" /f
    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell /v "ProgrammaticAccessOnly" /t REG_SZ /d "" /f
    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\Powershell /v "ProgrammaticAccessOnly" /t REG_SZ /d "" /f
    
    ::reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Powershell /f
    ::reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell /f
    ::reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\Powershell /f
    
    @ping 127.0.0.1>nul
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.