Skip to content
This repository was archived by the owner on May 17, 2026. It is now read-only.

eladkarako/context-menu-cmd-powershell-wsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open With CMD, PowerShell, Linux (WSL)

  1. run as administrator: --_1_permissions.cmd.
    it uses PsExec64.exe (https://learn.microsoft.com/en-us/sysinternals/downloads/psexec)
    and SetACL.exe (https://helgeklein.com/setacl)
    to run as SYSTEM and change ownership from TrustedInstaller to Administrators,
    ignore warnings, some of the keys do not exist on your machine. that's fine.

  2. run as administrator: --_2_cleanup.cmd.
    it imports cleanup_cmd.reg, cleanup_powershell.reg, cleanup_wsl.reg
    which have delete instructions, those too, include some keys that do not exist on your machine. that's fine too.

picture showing that all old items have been removed from the context-menu

those entries now have been removed!

adding items - option 1 - old-school.

picture showing that the items were back same as before, with icon

I advise you to use the newer option 2 - sub menu

you can choose to manually double click either of those:

  • option1__same_level__cmd__install.reg
  • option1__same_level__powershell__install.reg
  • option1__same_level__wsl__install.reg

which will bring them back, using normal ownership,
without Extended meaning they will not require you to hold SHIFT,
and without ShowBasedOnVelocityId and HideBasedOnVelocityId,
meaning they will not be hidden or shown unexpectedly in some cases. also, they will have the icon of their main execute.

the items will be just like before, spread across other context-menu items,
sorted by their name, meaning cmd and powershell will be on top,
and wsl will be last, and probably have few other items in-between.


adding items - option 2 - modern sub menu.

picture that shows a more modern menu with all group under one menu entry

  1. double click each of those, to make sure you have removed items from option 1.
  • option1__same_level__cmd__uninstall.reg
  • option1__same_level__powershell__uninstall.reg
  • option1__same_level__wsl__uninstall.reg
  1. double click option2__sub_level__command_prompts__base__install.reg
    it will install an empty menu without cmd, powershell, or wsl,
    and will add the link to Directory, Directory\Background, and Drive.

  2. now, choose either of those to populate (add items) to the menu.

  • option2__sub_level__command_prompts__cmd__install.reg
  • option2__sub_level__command_prompts__powershell__install.reg
  • option2__sub_level__command_prompts__wsl__install.reg

you can uninstall them later using each uninstall.reg file.
if you wish to uninstall the menu itself,
use option2__sub_level__command_prompts__base__uninstall.reg.


that's it...


adding your own...

some information...
  • if you have installed a terminal/console from the Microsoft Store or anything that uses SYSTEM as trusted installer,
    and not just admin (most Microsoft products),
    query the entries, use regedit.exe or Registry WorkShop (http://www.torchsoft.com/en/rw_information.html),
    export the old keys, add icon entry, and remove the extended and hide and show entries.

if you are able to use Registry WorkShop as admin (you can even force open keys),
or run it as SYSTEM using PsExec64.exe (https://learn.microsoft.com/en-us/sysinternals/downloads/psexec)
and change ownership/permissions manually, do it.
otherwise add the keys to __1_permissions.cmd
note the redundancy of having HKLM, HKCU, and HKCR
so SetACL.exe (https://helgeklein.com/setacl) will do the hard part for you.
then copy cleanup_cmd.reg rename it to note your terminal/console,
and make sure it has all the variations...
it is a lot safer than using REG.exe delete commands.

then choose either option1__same_level__cmd__install.reg or option2__sub_level__command_prompts__cmd__install.reg as your "template".
rename, add your commands and make an uninstall.reg .


some cool un/poorly documents stuff about registry stuff I use...

lets take a look at this for a second

[........\my_menu]
@=""                                   ; mandatory! you should not specify default value. as this is also used for command in simpler cases, it makes the entry show as non-menu.
"MUIVerb"="Command Prompts"            ; mandatory! specify here the caption. you can also use "MUIVerb"="@shell32.dll,-8508" to take from shell32.dll.mui under whatever language your windows has installed, the value from the string-table. which will change automatically as the OS language will change.
"MUIVerb.1033"="Command Prompt"        ; en-US
"MUIVerb.en-US"="Command Prompts"      ; en-US
"MUIVerb.2057"="Command Prompts"       ; en-GB
"MUIVerb.en-GB"="Command Prompts"      ; en-GB
"MUIVerb.1037"="שורת פקודה"            ; he-IL
"MUIVerb.he-IL"="שורת פקודה"           ; he-IL
"Icon"="cmd.exe,0"                     ; optional. adds an icon to the menu.
;"Position"="Top"                      ; optional. designed to order entry near bottom of entries. Bottom is near the "new..." part. Top is near "views"
"SeparatorBefore"=""                   ; optional. adds _____ before. only works for menus. for commands you need to use CommandFlags (bitwise OR) - ; optional. 0x20 before, 0x40 after. both: 0x60 (0x20 OR 0x40) - in browser console you can use "0x" + (0x20 | 0x40).toString(16) to get the 0x60 (that's 96 decimal). note that Windows will merge separators.
"SeparatorAfter"=""                    ; optional. adds _____ after.  only works for menus.
"subcommands"=""                       ; mandatory! empty string, as the commands are given in here direc
  • @="" menus should not have default value, since it can be used as shorthand of a command.
    you can either specify it having empty string, or DELETE instruction, using @=-
  • "subcommands"="", essentially it can "take" and key from around the registry.. I think. empty is fine, when the sub items are written below it.
  • if you either put a default value or forget the subcommands, your menu will just show as an item.
  • "Position"= - Top, Bottom was mixing with the "organic" items so I kept it in the middle (commented-out).
  • "SeparatorBefore"="", "SeparatorAfter"="" - those are unique to menus, and can not be used anywhere else, commands (sub items that are either having default value or sub key command) would have to include CommandFlagswhich can include the hexadecimal value of either0x20for separator before,0x40for after, or joining both using bitwiseORto0x60(96 decimal). there are other stuff you can combine into it... and you can use javascript from your browser for quick calculation..."0x" + (0x20 | 0x40).toString(16)`. the context-menu will merge separators so that's fine, you won't make a mess.

special paths.

cygwin and wsl have "special" mapping for linux like compatible paths,
wsl can handle the conversion itself, and for cygwin you can use either cygpath
or just do it yourself using string manipulation, and a small windows batch file,
converting from C:\Foo\Bar to /cygdrive/c/Foo/Bar (lower drive letter, forward slash, /cygdrive prefix).

launch it directly in bash or use mintty ( https://github.com/mintty/mintty )

you can probably get a quick batch file from any simple A.I. chat app ( https://duck.ai/chat ).


option 2 - sub menu was a little tricky (developer notes)..

first I defined a new "menu", under HKEY_CURRENT_USER\Software\Classes\ (I added another level \ContextMenus\ just to be options to add other menus in the future),
then all HKEY_CURRENT_USER\Software\Classes\Directory, HKEY_CURRENT_USER\Software\Classes\Directory\Background, and HKEY_CURRENT_USER\Software\Classes\Drive - just need to include "ExtendedSubCommandsKey"="ContextMenus\\menu_command_prompts"
which is a path relative to the user classes, without HKEY_CURRENT_USER\Software\Classes


some of the older notes:

  • the context-menu entries are created, explicitly, to the current user.
  • they are created like normal registry keys, so you can edit then normally afterwards.
  • modification: for wsl - I have added --distribution Ubuntu, explicitly.
  • modification: I have added for each, an icon based on the main executable (cmd, powershell, wsl).
  • modification: I have removed (commented-out) Extended so plain right click will show the entries.
  • modification: I have removed (commented-out) ShowBasedOnVelocityId and HideBasedOnVelocityId, since sometimes they hide the entries.

what YOU can do:

  • edit set_...reg files open them with a decent editor such as notepad++.
  • if you so wish, uncomment Extended lines, save, double click the file to apply it. it will make the entry only be shown when holding SHIFT.
  • manually change the lines @="@shell32.dll,-8506", replacing @shell32.dll,-8506 with your own text. in whatever language you want.
  • change command lines, for example @="wsl.exe --distribution Ubuntu --cd \"%V\"" you can re-remove --distribution Ubuntu or change the distribution name.

  • you don't have to reboot, nor restart explorer.exe all changes can be done right away by embedding the various .reg files (double click.
  • make sure to edit the .reg files using notepad2 or notepad++ or anything which explicitly sets the Windows-EOL (end of line).

here are related registry tweaks you might be looking for copy to .reg file and double click to embed:

classic right click context menu in windows 11

;;----------------------------------------------- restores normal right-click context menu. effects W11.
[HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32]
@=""

<4>make sure all your items are shown even if you select a lot of files and folders

;;----------------------------------------------- allow showing context-menu items, even if 100 files are selected (default is 15 - "MultipleInvokePromptMinimum"=dword:0000000F  or "MultipleInvokePromptMinimum"=- )
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer]
"MultipleInvokePromptMinimum"=dword:00000064


About

fix for the right click context-entries for open in cmd, powershell and wsl. you can use this as an example for taking ownership from TrustInstaller and changing access control entries as SYSTEM (PsExec, SetACL)

Topics

Resources

License

Stars

Watchers

Forks

Contributors