There's a fairly easy way to do this if you know your way around the registry editor.
First of, open up regedit
and navigate to HKEY_CLASSES_ROOT\Directory\shell
.
There's a couple of locations where we can add those keys, HKEY_CLASSES_ROOT\Directory\shell
will add an option in the context menu of folders.
You should have a couple of existing keys in there, most notably cmd
which is the Open command window here
option.
Once you're in that folder, let's create a new key (right click -> New -> Key
), call it what you want. Now change the data of the (Default)
value to whatever you want to be displayed in your context menu in Windows Explorer.
![After you've created the key and changed the (Default) value's data](../../I/static/images/c4651e04f0538467c2a010598d6a2e6156af7f8156e1f723c752c28d29a56da6.png)
Now under your new key, you have to create another key called command
and set it's (Default)
data to the command you want to execute. You can use %V
for the current folder. See this question for details about the arguments you can use: Which special variables are available when writing a shell command for a context menu
Now if you want to add an option when you click on Windows Explorer's background (any white space in the right pane of Explorer), you'll have to do the same thing, but add a key in HKEY_CLASSES_ROOT\Directory\shell\Background
.
![Example of a key in both the background and folders directory](../../I/static/images/693f40b89e056fd4f3d3080d5be95a1b5218b772b9404e064caa3a542d5c164e.png)
If you want to add an option in the Context Menu for a specific file extension, you'll just have to find the proper class and add another key in it's shell
folder like so:
![Add a shell option to jpgs](../../I/static/images/681b703d8b61e849856adcd7367de436225448edc3f4771984518dd9a540f6cd.png)