ERCC (http://eriedel.info)

Extending Explorer Context Menu


The Windows Explorer offers various options via a context menu, including those that can be applied to currently selected files and folders. These menu options can be expanded to include your own entries, in particular to allow additional treatment for the selection. For this, a program that carries out this processing is called up. This can be arranged in two ways: by including it in the existing Send to option or by setting up special keys in the Windows Registry.  1  

The first method is simpler and less risky than the second and therefore preferable. Another advantage is that the new option becomes part of the "Send to" submenu so that the first menu level remains clear.

In any case, you should be familiar with the usage of the programs involved (Explorer or RegEdit), proceed carefully and also be aware that you use the information provided here at your own risk!

I'll describe both methods using the example of the script file for folder copies. An adaptation for other program calls is easily possible by changing the corresponding file and option names.

The script file name is foldercopy.vbs or foldercopyx.vbs. In this description I will refer to the first file. (Of course you can as well use the second file or create two menu items for both versions.)
I assume the folder C:\Tools as its storage location. If necessary, change this value to the directory you are using.
This results in, for example, C:\Tools\foldercopy.vbs as the complete file name.

The new menu option is given the name "Folder Copy ...". This naming adheres to the standard, that options which lead to the display of a dialog box (in this case the folder selection) are discernible by an appended ellipsis (three dots). This provides a visible difference from options that immediately trigger an action.
(Of course, the option name can also be some other informative short text such as "Copy to ...").


SendTo

The Send to option is supplemented at the file level. To do this, a shortcut to the desired program is created in a specific user folder (SendTo). This can easily be done with the Explorer. The necessary functions are available via the context menu and partly also via key combinations.

1. Creating a shortcut for the target file

Start the Explorer and switch to the folder where the script file foldercopy.vbs is located. In the example this would be C:\Tools. Call up the context menu for this file (right mouse click or Menu key) and select the option Create shortcut. A shortcut file with the likely name foldercopy.vbs - Shortcut is created in the folder.

2. Moving the shortcut file

Select and cut this new file (context menu or Ctrl+X).
Then change to the SendTo folder.

The easiest way is to enter the term shell:sendto in the address bar of the Explorer, completing this entry with the Enter key. This takes you directly to the folder of the current user.

Alternatively, you can also select the folder in the folder tree view. The full path for a user named "Xyz" is:
C:\Users\Xyz\AppData\Roaming\Microsoft\Windows\SendTo
So you need to know your username and step through these directory levels. (Note that the Explorer shows the main user folder in a language-specific manner. Hence you would start with C:\Benutzer in a German Windows version.)

Now, in the SendTo folder paste back the shortcut file (context menu or Ctrl+V).

3. Rename shortcut

Finally, you should change the name of the file to the desired designation of the menu option.


Deleting the context menu entry

To remove the menu item from the Send to options, delete the shortcut file in the SendTo folder.


Registry

Another way to extend Explorer's context menu is by defining new options through specific registry entries. The registry is a configuration database that contains a great deal of information, including crucial settings for the Windows operating system. Hence, making incorrect changes can have quite adverse or fatal consequences.
Inexperienced users are therefore strongly advised not to use this method!

Windows provides the registry editor RegEdit, which displays the database content in an Explorer-like view. Editing functions can be accessed via a main menu and a context menu.

1. Creating the Explorer option

Start the registry editor and navigate to the following path:
HKEY_CLASSES_ROOT\*\shell
There you create a new key with the desired name of the action, i.e. the option of the Explorer context menu. According to the definition above, this is "Folder Copy ...".

2. Defining the program command

Now select the new key and create a subkey with the name "command".
Change the "(Default)" value for this key to the program command:
C:\Windows\System32\WScript.exe C:\Tools\foldercopy.vbs %1

Normally, such a command simply consists of the complete file name of the program and —if required— the appended token "%1" (separated by a space), which represents any program parameters. To call a script file, however, it is necessary here to explicitly start the actual executing program (the Windows Script Host). Therefore the program command for the registry is more complex than with a SendTo shortcut.

So you have now created this registry entry:
HKEY_CLASSES_ROOT\*\shell\Folder Copy ...\command

with this key value:
C:\Windows\System32\WScript.exe C:\Tools\foldercopy.vbs %1
(or whatever folder or file name you use).

3. Creating the Explorer option for folders

The option defined in the previous two steps is now available for files, but not yet for folders. In order to have this program command usable also on folders, a second registry entry is required, with otherwise the same keys and values.

For this, switch to the following path:
HKEY_CLASSES_ROOT\Directory\shell

Again create a key for the menu option ("Folder Copy ...") and in it a "command" subkey. Here, too, change the default value of this key to the program command.

So, the second new registry entry is:
HKEY_CLASSES_ROOT\Directory\shell\Folder Copy ...\command

The key value is identical to the first.


Deleting the context menu entry

To remove the command option, delete the registry keys created for it. These are the keys with the option name, created in the 1st and 3rd step. This also deletes the keys and values contained therein.


Note

The aforementioned registry paths are effective for all users.
In order to restrict the changes to the current user, the new keys have to be created under the following paths instead:
HKEY_CURRENT_USER\Software\Classes\*\shell
and
HKEY_CURRENT_USER\Software\Classes\directory\shell

It is possible that some of the superordinate keys do not exist already, in which case they have to be created too, to attain the complete registry paths as shown.



Remarks:

1 To the user, a third way is open, because various sources offer applications for changing or managing the Explorer context menu. (These programs generally work with registry keys, i.e. the second method shown here.)



http://eriedel.info/en/info/explorermenu.html


ERCC (http://eriedel.info)  01/2021   © Erhard Riedel Computer Consulting (ERCC)


link to info overview