What you're asking about is not programming, but system administration.
The HKEY_CLASSES_ROOT hive basically maps extensions to actions. It's actually more complicated than that, but for a basic understanding this simplification will suffice.
Start Regedit and take a look at the key [HKCR\.txt]. You'll notice the string "txtfile" in the
Default value. Now take a look at [HKCR\txtfile]. You have two subkeys there:
DefaultIcon and
shell. The
shell subkey has several subkeys as well:
open,
print and
printto. These are the actions Windows has registered for text files. The
command subkey of either of these actions specifies the command that is executed when the action is invoked. In case of
open that command is "%SystemRoot%\system32\NOTEPAD.EXE %1", i.e. "run Notepad and have it open the given file".
The Windows Explorer shows these actions in the context menu of a file or folder. Change the
Default value of an action to an arbitrary string, and that string will be displayed as the caption instead of the key name. The default action (the fat entry in the context menu) is
open, but it can be changed by specifying a different action in the
Default value of the
shell key.
Example:
[HKEY_CLASSES_ROOT\txtfile\shell]
@="print"
[HKEY_CLASSES_ROOT\txtfile\shell\open]
@="Open Sesame"
This would change the default action for text files to
print, and also change the caption of the
open action to "Open Sesame".
Now, what you need to do to add your script to the context menu is:
- find a suitable file type
- create a new action (e.g. createdir) under the shell key of that file type
- create a command key under the action
- specify the command, e.g. "wscript.exe C:\PATH\TO\your.vbs %1"
HTH