Assume you add "Edit with Vim" command to the context menu of .txt
file. This extension is usually associated with txtfile
key. The commands are listed in the shell
subkey. The default value of the command key is the name of the command displayed in the context menu. If you add &
before any of the characters, then the following character becomes the keyboard accelerator.
Let me explain using an example.
HKEY_CLASSES_ROOT
.txt
(Default) = txtfile
txtfile
shell
EditInVim
(Default) = Edit with Vim
In this case, the command Edit with Vim would not have an accelerator key. Change the value to Edit with &Vim
, and then V
would be underlined and pressing it will invoke the command.
If your editor uses a context menu handler to add the item to the context menu, then the only way to change the accelerator key is to edit the string resources in its executable file.
I didn't answer the original question though.
The default Edit command for text files comes from the following registry keys:
HKEY_CLASSES_ROOT
SystemFileAssociations
text
shell
edit
(Default) = (value not set)
The shell make the first letter the accelerator. To change it, assign the value to (Default)
:
(Default) = E&dit
The accelerator for Edit command has changed to d
now.
The first thing you need to do is set the Command
string (Right Click > New > String Value) to %SystemRoot%\System32\cmd.exe /c "%SystemRoot%\ShellNew\WordTemplates.bat ^"%1^""
(assuming that the templates are at C:\Windows\ShellNew).
Then, create a new file at C:\Windows\ShellNew\WordTemplates.bat. In this file, place the following lines of code:
@echo off
echo What document would you like to create?
echo 1 - Template 1
echo 2 - The best template
echo 3 - Sample template
echo 4 - Template 4
echo 5 - Template 5
echo 6 - Template 6
echo 7 - Template 7
echo 8 - Template 8
echo 9 - Template 9
echo 0 - Template 10
choice /c 123457890>nul
copy "%SystemRoot%\ShellNew\Template%errorlevel%.docx" %1>nul
You can replace the descriptions of each template to your preference. The file names of each template must be Template1.docx, Template2.docx, ..., Template10.docx, Template11.docx, etc. The code above will only allow 10 templates. If you would like to specify 26 templates, you can use the alphabet as the choices. You can also change the file extension to .doc
.
Best Answer
Here is the reg file for adding shell new entry for .php & .html
Now create a
htmlfile.html
file in your Windows\ShellNew folder and enter default html :