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.

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
.

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:
