55

Shift-rightclicking an empty spot in Explorer displays "Open with PowerShell" instead of "Open with Command Prompt" since the Creators Update (2017-04). How can I get the old behaviour back where it shows "Open with Command Prompt"?

I tried changing the setting "Show PowerShell instead of Command Prompt when rightclicking the Start Menu or pressing Windows + X" to off, but that didn't change the shift+rightclick menu.

10 Answers 10

60

Open regedit.exe, go to HKEY_CLASSES_ROOT\Directory\shell\cmd, take ownership of the key, add your user account full permissions and change the name of the DWORD from HideBasedOnVelocityId to ShowBasedOnVelocityId to enable the command prompt entry again.

Enter image description here

Or apply Andrew Richards tweak to have both shown (cmd and PowerShell, also with entry to have elevate (running as admin) version),

Enter image description here

Enter image description here

by importing his .reg file (create a new txt file, paste the content and rename the file extension to reg):

Windows Registry Editor Version 5.00

; Command Prompt

[HKEY_CLASSES_ROOT\Directory\shell\01MenuCmd]
"MUIVerb"="Command Prompts"
"Icon"="cmd.exe"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\MenuCmd"

[HKEY_CLASSES_ROOT\Directory\background\shell\01MenuCmd]
"MUIVerb"="Command Prompts"
"Icon"="cmd.exe"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\MenuCmd"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuCmd\shell\open]
"MUIVerb"="Command Prompt"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuCmd\shell\open\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuCmd\shell\runas]
"MUIVerb"="Command Prompt Elevated"
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuCmd\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""


; PowerShell

[HKEY_CLASSES_ROOT\Directory\shell\02MenuPowerShell]
"MUIVerb"="PowerShell Prompts"
"Icon"="powershell.exe"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\MenuPowerShell"

[HKEY_CLASSES_ROOT\Directory\background\shell\02MenuPowerShell]
"MUIVerb"="PowerShell Prompts"
"Icon"="powershell.exe"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\MenuPowerShell"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuPowerShell\shell\open]
"MUIVerb"="PowerShell"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuPowerShell\shell\open\command]
@="powershell.exe -noexit -command Set-Location '%V'"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuPowerShell\shell\runas]
"MUIVerb"="PowerShell Elevated"
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuPowerShell\shell\runas\command]
@="powershell.exe -noexit -command Set-Location '%V'"


; Ensure OS Entries are on the Extended Menu (Shift-Right Click)

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\background\shell\cmd]
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\shell\Powershell]
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\background\shell\Powershell]
"Extended"=""
12
  • 1
    The 2nd method in your answer is good. But for someone who has no idea what to do with the .reg, just copy the file text into a .txt file & rename the file <name>.reg & double click it to run. Even though there is error message, the operation is success – KharoBangdo Sep 5 '17 at 4:41
  • 2
    How to restore from these reg keys? – vee Jan 13 '18 at 14:41
  • 3
    This answer didn't work for me until I applied the solution to all three of these registry paths: HKEY_CLASSES_ROOT\Directory\Background\shell\cmd, HKEY_CLASSES_ROOT\Directory\shell\cmd, and HKEY_CLASSES_ROOT\Drive\shell\cmd as directed here – Terrance Sep 5 '18 at 13:47
  • 1
    That .reg file works like a charm. – MC Emperor Sep 14 '18 at 22:03
  • 1
    @sdaau the blog is back online after MSFT restored all deleted blogs – magicandre1981 Apr 24 '19 at 13:35
19

As a quick alternative to the other answers, you can type cmd on the address bar of Explorer to open a command prompt cd'd to the current directory. (If you are more of a keyboard person, you can use the Ctrl + L shortcut to focus the address bar and then type cmd.)

This works for powershell too.

7

This is extremely easy to accomplish

  • In the Taskbar and Start Menu Properties window, go to the Navigation tab and uncheck the Replace Command Prompt with Windows PowerShell option.
  • Click Apply for the change to take effect.

enter image description here

Sources:

enter image description here

Additional Source:

2
  • 19
    This only changes the Windows + x menu, not the "Open with" menu when shift + rightclicking an empty spot in Explorer. – nelson2tm Apr 21 '17 at 17:12
  • 2
    no Ramhound this doesn't work. you ONLY change what shows up in WinX menu on right click on start button, not doing a rightclick inside Windows/File Explorer – magicandre1981 Nov 3 '17 at 15:13
2

To hit all of the locations where Windows has changed this, you can use the following registry file after taking ownership of each key in question.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd]
"ShowBasedOnVelocityId"=dword:00639bc8
"HideBasedOnVelocityId"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell]
"HideBasedOnVelocityId"=dword:00639bc8
"ShowBasedOnVelocityId"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd]
"ShowBasedOnVelocityId"=dword:00639bc8
"HideBasedOnVelocityId"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell]
"HideBasedOnVelocityId"=dword:00639bc8
"ShowBasedOnVelocityId"=-

[HKEY_CLASSES_ROOT\Drive\shell\cmd]
"ShowBasedOnVelocityId"=dword:00639bc8
"HideBasedOnVelocityId"=-

[HKEY_CLASSES_ROOT\Drive\shell\Powershell]
"HideBasedOnVelocityId"=dword:00639bc8
"ShowBasedOnVelocityId"=-

I would just take ownership of the [HKCR\Directory] and [HKCR\Drive] keys recursively and force permission inheritance.

Registry Permissions and Ownership setting

1

To summarize all research and improving Andrew Richards registry tweak, I got rid off annoying sub-menus by utilizing single runas verb for legacy command prompt and implementing elevated entry for PowerShell using Start-Process from non-elevated instance called by cmd.exe:

[HKEY_CLASSES_ROOT\Directory\Background\shell\ps_uac_usr\command]
@="cmd /C powershell \"start powershell -a '-noexit -command Set-Location ''%V''' -v RunAs\""
  • v flag specifies Verb set to RunAs triggers elevation via UAC prompt;
  • a stands for ArgumentList that passes noexit option that prevents new PS window from closing upon start and Set-Location option is self-explanatory;
  • %Vpasses initial path for new command prompt (when file(s)/folder(s) is selected it will pass the location of item that was right-clicked on, if nothing is selected it is equal to working directory);
  • note, \ escaping double-quotes dictated by reg file syntax as line should be seen as @="<command>", where <command> is what actually ends up in key value data;
  • and the most critical part is proper use of ' necessary to specify that first instance of PowerShell should not parse quoted contents at all and pass arguments literally while preserving set of ' for final PowerShell to be able to ignore any rogue & (%V variable is expanded by explorer.exe prior to any execution, so we don't have to worry about it).

Nothing new, but it makes sense since this implementation preserves backwards compatibility. Legacy cmd will start even if PowerShell executable does not exist.
Combination of runas registry key placed directly inside shell key is what grants permissions. And since there may be only one such key in any unique shell key, hence the limitation that forced Andrew to not only use use sub-menus, but make them separate for CMD/PS instead of single sub-menu.
By using single root runas key for elevated cmd.exe explicitly and spawning other entries with PowerShell, it is possible to avoid annoying sub-menus.

So my custom .reg file looks like this:

Windows Registry Editor Version 5.00

; CMD

[HKEY_CLASSES_ROOT\Directory\Background\shell\q_cmd_usr]
@="@shell32.dll,-8506"
"Extended"=""
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\q_cmd_usr\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Directory\shell\q_cmd_usr]
@="@shell32.dll,-8506"
"Extended"=""
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\q_cmd_usr\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Drive\shell\q_cmd_usr]
@="@shell32.dll,-8506"
"Extended"=""
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Drive\shell\q_cmd_usr\command]
@="cmd.exe /s /k pushd \"%V\""

; CMD (Elevated)

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="@shell32.dll,-8506"
;"Extended"=""
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="@shell32.dll,-8506"
"Extended"=""
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Drive\shell\runas]
@="@shell32.dll,-8506"
"Extended"=""
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

; PS (Elevated)

[HKEY_CLASSES_ROOT\Directory\Background\shell\ps_uac_usr]
@="@shell32.dll,-8508"
"Extended"=""
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\ps_uac_usr\command]
@="cmd /C powershell \"start powershell -a '-noexit -command Set-Location ''%V''' -v RunAs\""

[HKEY_CLASSES_ROOT\Directory\shell\ps_uac_usr]
@="@shell32.dll,-8508"
"Extended"=""
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\shell\ps_uac_usr\command]
@="cmd /C powershell \"start powershell -a '-noexit -command Set-Location ''%V''' -v RunAs\""

[HKEY_CLASSES_ROOT\Drive\shell\ps_uac_usr]
@="@shell32.dll,-8508"
"Extended"=""
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\shell\ps_uac_usr\command]
@="cmd /C powershell \"start powershell -a '-noexit -command Set-Location ''%V''' -v RunAs\""

If possible to avoid modifications to existing entries behavior, it is much less messy to instead of taking ownership of system entries in registry, simply create own. This should explain why I reused default entry which is missing icon and why the only difference of elevated prompt entries is a tiny shield icon. Instead of hardwiring text captions to specific language, lines like @="@shell32.dll,-8506" allow entries to stay localized.

Using ; to comment/uncomment "Extended"="" line allow to unhide/hide respectively this entry form default right-click menu. Hidden one is still accessed by Shift + Right Click. In my registry file, entry for elevated cmd is show by default, rest is hidden behind Shift+RMB.

Directory\shell path corresponds to right click on any folder,
Drive\shell to system drives,
Directory\Background\shell to background area of working directory in Explorer window.

By my observation, entries in right-click context menu are sorted in alphanumeric order, the same as they are read from registry. This should explain names for keys in my reg file, other than that they better be pretty unique to not collide with anything possible.

0

A workaround without admin rights (e.g. without changing registry):

WINDOWS + R: shell:sendto (open Explorer in the send to directory of the current user (or go there manually with C:\Users\<user>\AppData\Roaming\Microsoft\Windows\SendTo.

Create a new .bat-file with cmd as only text (e.g. _cmd_here.bat).

You can now right-click on any file in the desired directory (with or without shift) -> send to -> _cmd_here.bat and the command line is opened in the directory of this file.

This costs you one click (actually mouseover) more to go into the send to submenu and you need at least one file in the directory, but beside that I think it is a solution for the problem.

0

Here’s how to replace PowerShell with CMD:

  1. Open Registry Editor, simply by searching “regedit” on Cortana/Search or via Run (Win + R)
  2. On the address bar in the Registry Editor, paste “Computer\HKEY_CLASSES_ROOT\Directory\Background\shell” and hit enter
  3. From the sidebar, find “cmd” and right-click, then select Permissions
  4. From the permissions dialog, hit Advanced
  5. Hit the Change button next to the Owner field on the top of the Advanced dialog
  6. In the input field, enter your username — this can also be the email address for your Microsoft Account. Hit enter after typing in your username/email
  7. Back in the Permissions window, select Administrators from the top section and allow Full Control by checking the Allow check box on the dialog, then apply the changes and close the window
  8. Now, delete the DWORDHideBasedOnVelocityId” for CMD from the Registry Editor
  9. You may need to restart the File Explorer from the task manager to see the changes in action.

The above method will show CMD on the context menu when your Shift + Right Click in the File Explorer. But if you want to get rid of PowerShell, you can do so by following the steps below:

  1. Follow steps 1-7 from above — but change the permissions for “PowerShell” instead of the CMD.
  2. Once you apply the new permissions for PowerShell, delete the DWORD “ShowBasedOnVelocityId” for PowerShell
  3. After that, create a new DWORD and call it “*HideBasedOnVelocityId*
  4. Double click the newly created DWORD and change the hexadecimal value to “639bc8
  5. Once again, You may need to restart the File Explorer from the task manager to see the changes in action.
0

The following instructions will restore the Open command window here context menu item, keeping the existing Open Powershell window here context menu item. Tested under Windows 10 1909.

  1. Press the Window key + R

  2. Type regedit. Click OK button

  3. To the Do you want to allow this app to make changes to your device? question, click Yes

  4. In regedit, navigate to Computer\HKEY_CLASSES_ROOT\Drive\shell\cmd by copying and pasting the registry path into the address bar at the top

  5. Right-click on cmd key in the left pane > Permissions... > Advanced button

  6. In the resulting window, click the Change hyperlink, next to Owner: at the top. By default the owner is Trusted installer

  7. In the resulting window, enter your username and click Check Names button. Click the OK button once it has recognised your username

  8. Back on the previous screen, working from top to bottom:

    • Tick Replace owner on subcontainers and objects
    • Click the Enable Inheritance button
    • Tick Replace all child object permission entries with inheritable permissions from this object
    • Click OK
    • Click Yes to the Do you wish to continue? question
    • Click OK again
  9. Back in regedit, in the central pane, right-click HideBasedOnVelocityId and from the context menu choose Rename. Rename the value to ShowBasedOnVelocityId

  10. Navigate to Computer\HKEY_CLASSES_ROOT\Directory\shell\cmd via the address bar and repeat steps 5-9

  11. Navigate to Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\cmd via the address bar and repeat steps 5-9

  12. Close regedit

  13. Reboot your computer

Note: You may have to redo some of the changes after a Windows feature update.

-1

This hides powershell from the Shift-Right Click context menu and makes cmd visible.

Using a simple text editor such as Notepad, save the following code to a file with the .REG extension (e.g. MyImport.reg). Then double-click the saved file and follow the prompts to import it into the Registry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd]
"ShowBasedOnVelocityId"=dword:00639bc8

[HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell]
"HideBasedOnVelocityId"=dword:00639bc8

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
"ShowBasedOnVelocityId"=dword:00639bc8

[HKEY_CLASSES_ROOT\Directory\shell\Powershell]
"HideBasedOnVelocityId"=dword:00639bc8

[HKEY_CLASSES_ROOT\Drive\shell\cmd]
"ShowBasedOnVelocityId"=dword:00639bc8

[HKEY_CLASSES_ROOT\Drive\shell\Powershell]
"HideBasedOnVelocityId"=dword:00639bc8
3
  • Without explaining what this does and how to use it, this is not an answer. Please edit your post to clarify. – I say Reinstate Monica Dec 20 '18 at 11:35
  • done!.......... – Riccardo La Marca Dec 20 '18 at 11:44
  • 1
    Better, however see my edit for more of what I was expecting (not all users will know how to import content into the Registry). – I say Reinstate Monica Dec 20 '18 at 12:33
-3

In Windows 10 this is now included in the taskbar settings.

Windows 10 Taskbar Settings

1
  • 3
    "This only changes the Windows + x menu, not the "Open with" menu when shift + rightclicking an empty spot in Explorer." -nelson2tm – Mattwmaster58 Apr 10 '18 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.