136

When I right click anywhere I get an option to add a new file with a specified extension. I would like to add some custom files into this menu, so I can right click and create a new PHP file for instance.

How can I do this?

Bogdan Lataianu
  • 639
  • 3
  • 10
  • 25
  • try new menu editor tool included in Right Click Enhancer at http://rbsoft.org/downloads/right-click-enhancer – Ravi Patel Dec 15 '12 at 07:50
  • 2
    If you are having problems adding an entirely new file extension (rather than simply adding `NullFile`/`FileName` to an existing entry) in Windows 7, then see this other question... http://superuser.com/questions/588647/cant-add-new-items-to-windows-7-new-context-menu – MrWhite Nov 01 '13 at 10:58
  • 2
    [Ramesh’s site](http://windowsxp.mvps.org/shellnewadd.htm) is a good source for manually adding entries. – Synetech Nov 10 '13 at 15:47
  • I tried the below approaches but w/o success. There's probably another obscure registry setting I'm missing. Anyway, it's really not worth wasting time on. – HappyNomad Mar 13 '20 at 16:44
  • I tried [this](https://www.techrepublic.com/article/how-to-add-a-new-file-type-to-the-microsoft-windows-10-context-menu/) for Windows 10 and it works. I add png file to the new list. – zar Nov 17 '20 at 18:50

11 Answers11

75

One more thing:

If you want to add a file as a template for the new item, use

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.html\ShellNew]
"FileName"="html.html"

and then place the file (html.html) in:

  • For your own profile: %Userprofile%\Templates
  • For all users: %Allusersprofile%\Templates
  • For the whole system: %Systemroot%\ShellNew

One more detail: if you want to delete the "Windows Live Call" entry, use:

[-HKEY_CLASSES_ROOT\.wlcshrtctv2\LiveCall\ShellNew]
Daniel B
  • 60,360
  • 9
  • 122
  • 163
Eduardo Molteni
  • 1,708
  • 6
  • 26
  • 36
  • Cool thought, to able to use a file as a template! – Clay Nichols Jan 28 '11 at 20:02
  • 2
    In case anyone is wondering, the `FileName` entry appears to override the `NullFile` entry mentioned in other answers. You don't seem to need to delete an existing `NullFile` value. However, having both entries does seem to confuse some other 3rd party utilities, such as [NirSoft's ShellMenuNew](http://www.nirsoft.net/utils/shell_menu_new.html). (Windows 7) – MrWhite Nov 01 '13 at 10:55
  • 2
    I don't think it needs to be in %Userprofile%Templates etc if you give the whole path name to the file. – jiggunjer Jun 20 '15 at 02:39
  • 3
    What do I do if I want to create two shortcuts to two different templates for the same program? For instance, I used this method perfectly to create a context menu item for an "article" template for TeXworks. I now want to also add a "modified_article" template for TeXworks. Can I add both to the context menu? Thanks! – Prahar May 22 '16 at 18:19
  • @Prahar That's a [new question](https://superuser.com/questions/ask) you should ask [separately](https://superuser.com/questions/ask) – Tobias Kienzler Jul 15 '16 at 11:12
  • 3
    In Windows 8.1, the Templates folders you list do not work. I get an "access denied" error. Where Templates should be is now a shortcut folder thing called a "junction" apparently--and it is a hidden "operating system specific" file. Therefore, the Templates folder is now moved. See this link for the new mapping (https://jimmah.com/vista/Security/junctions.aspx). Apparently it's now `C:\Users\USER_NAME\AppData\Roaming\Microsoft\Windows\Templates` for your own profile, for example. – Gabriel Staples Oct 30 '16 at 20:29
  • ...but I can't get your answer to work for me regardless. Don't know why. – Gabriel Staples Oct 30 '16 at 23:19
  • If you specify a FileName instead using NullFile, the system looks for a template file by that name in %windir%\ShellNew. For instance, the directory on my system contains EXCEL12.XLSX, and the registry entry specifies FileName REG_SZ excel12.xlsx – trindflo Jul 31 '17 at 18:01
  • I just want to add that his works even for [syspreping](https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/sysprep--generalize--a-windows-installation) if you place the template in `C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Templates` – Arete Jan 12 '18 at 12:16
71

To add extensions of your choice to the list: create a file, add the content below, save it as whatever.reg, and run it.

Note: Replace .png with the file extension you want to add and replace whatever with anything you want.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.png\ShellNew]
"NullFile"=""

Source

th3dude
  • 9,441
  • 6
  • 47
  • 67
  • 1
    This didn't work for me in Windows 7. I had two other existing keys below ".doc" (PersistentHandler and Word.Document.8.) Could that interfere with this? The contents of the .reg file I added to my Reg were: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.doc\ShellNew] "NullFile"="" – Clay Nichols Jan 31 '11 at 15:15
  • @Clay: Did you try a restart? – surfasb Nov 20 '11 at 19:29
  • This didn't work for me when I tried to add a .tex extension for LaTeX editing. I did try a restart. – Lokathor Jan 11 '12 at 09:13
  • 1
    +1, this works. How can we have a custom filename like "index.php" instead of that "New PHP file.php"? – fedmich Sep 28 '12 at 03:14
  • 1
    I had to run the `.reg` file twice to make it work. Thank you for this answer. – Aakash Mar 15 '16 at 13:00
  • Didn't work for me in Windows 8.1 :( I retried repeatedly, and restarted too. – Gabriel Staples Oct 30 '16 at 21:19
  • 7
    Didn't work for me in Windows 10, 1709 :( Restarted explorer and restarted machine even, still... – Arete Jan 12 '18 at 11:29
18

ShellNewHandler helped me to restore my Windows 7 shell menu > New > txt document entry.

enter image description here

  1. Uncheck .txt
  2. Click Apply
  3. Check .txt
  4. Click Apply
Gaff
  • 18,569
  • 15
  • 57
  • 68
Eric
  • 205
  • 2
  • 2
18

Go in to registry editor and expand HKEY_CLASSES_ROOT

Go to .file_extention

and create a key called ShellNew

Inside that, create a new string key called NullFile with no value

For example, if I wanted to create a new entry for a blank .wil object* I would create

[HKEY_CLASSES_ROOT\.wil\ShellNew]
NullFile = ""

*if the file extension such as .wil does not exist, I would first create a file with that extension and double click it. Open it with the program of my choice as this would then create the other needed registry keys and make your job easier.

William Hilsum
  • 116,650
  • 19
  • 182
  • 266
  • 4
    Dosen't work on Windows 10, also I found this article, but this not working either: http://www.askvg.com/how-to-add-remove-items-from-new-menu-in-windows/ – Neo Apr 29 '16 at 22:28
14

It seems that the other solutions here are outdated. At least none of these worked for me in Windows 10 v. 1709 Build 16299.192 (Edit: still works in version 1809). I did some testing in a VM and this is what works in Windows 10 1709, as of 2018.01.12:

Add the registry file:

Create a new registry file file with the following content:

Windows Registry Editor Version 5.00

; new file type
[HKEY_CLASSES_ROOT\.xyz]
@="xyz"

; template
[HKEY_CLASSES_ROOT\.xyz\ShellNew]
"FileName"=""

; file type name
[HKEY_CLASSES_ROOT\xyz]
@="XYZ test file"

Replace xyz with the extension you would like to add. And replace XYZ test file with the name of the file extension (e.g a .scss file would be "syntactically awesome style sheet file”). If you want to use a template file see the explanation below.

It might be necessary to restart Windows Explorer after you have added the registry file. You can restart explorer.exe by typing the following in CMD:

taskkill /f /im explorer.exe & start explorer.exe

enter image description here

enter image description here


Explanation of the code:

[HKEY_CLASSES_ROOT\.xyz]
@="xyz"

Will create a new file type in the registry.

[HKEY_CLASSES_ROOT\.xyz\ShellNew]
"FileName"=""

This will enable you to use a template for all new files of this file format. We could for example write "template.xyz" and make a new file called “template.xyz” and use it a s a template. So each time you make a new file it will be populated with pre-made content. As Eduardo Molteni mentioned the paths for the template files are: %Userprofile%\Templates, %Allusersprofile%\Templates or for the whole system %Systemroot%\ShellNew. In this example we haven’t specified any template name because we don’t want to use any.

[HKEY_CLASSES_ROOT\xyz]
@="XYZ test file"

This will be the name of the file type both for the context menu and the newly created files. As far as I know leaving this value blank does not work.

Icon:

The icon is added once Windows have associated a software with the file type.

Arete
  • 1,321
  • 7
  • 28
  • 50
6

None of these methods were working for me in Windows 10.

I finally found this page that explained that you need to reference another key that contains the name and default icon.

This is the minimum needed to create an entry, but it won't have an icon.

NOTE: the third entry is for a new key textfile referenced in the (Default) value of .txt

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.txt]
@="textfile"

[HKEY_CLASSES_ROOT\.txt\ShellNew]
"NullFile"=""

[HKEY_CLASSES_ROOT\textfile]
@="Text Document"

Here are two ways to specify an icon

  1. Tell Explorer to use the default icon for the content type:
[HKEY_CLASSES_ROOT\.txt] 
@="textfile" 
"Content Type"="text/plain"
"PerceivedType"="text"

or 2. Specify an icon under textfile like so:

[HKEY_CLASSES_ROOT\textfile\DefaultIcon]
@="%SystemRoot%\\system32\\imageres.dll,-102"

Oh, and at least for me, just closing and reopening Explorer (make sure to close all instances) is enough to reload the context menu. You don't need to restart the whole machine.

subman
  • 2,197
  • 13
  • 16
  • At my side "Notepad++" changed the `HKEY_CLASSES_ROOT\.txt` to `@="Notepad++_file"`. So adding `HKEY_CLASSES_ROOT\Notepad++_file` with `@="Textfile"` did the trick. Thanks, good find! – Tino Jul 28 '17 at 20:38
6

For removing entries from the list, here is a program which allows you to enable/disable entries from a GUI. Much easier than searching the registry!

Unfortunately, it does not allow you to add entries.

Blorgbeard
  • 2,845
  • 3
  • 30
  • 31
  • This is just what I needed, thanks! Generally, all you really need is "New Text Document"... – Andrew Jun 14 '11 at 15:51
4

You didn't say what version of Windows you're using--if it's XP you can download the TweakUI PowerToy from Microsoft (also covered in Wikipedia). Click on Templates and add/remove file types to your heart's content. Here's what it looks like: enter image description here

User5910
  • 536
  • 1
  • 4
  • 19
2

This information is all officially documented by Microsoft; normally intended for developers who are registering their own new file types.

Extending the New Submenu

When a user opens the File menu in Windows Explorer, the first command is New. Selecting this command displays a submenu. By default, it contains two commands, Folder and Shortcut, that allow users to create subfolders and shortcuts. This submenu can be extended to include file creation commands for any file type.

To add a file-creation command to the New submenu, your application's files must have a file type associated with them. Include a ShellNew subkey under the key for the file name extension. When the File menu's New command is selected, the Shell will add it to the New submenu. The command's display string will be the descriptive string that is assigned to the program's ProgID.

Assign one or more data values to the ShellNew subkey to specify the file creation method. The available values follow.

  • Command: Executes an application. This is a REG_SZ value specifying the path of the application to be executed. For example, you could set it to launch a wizard.
  • Data: Creates a file containing specified data. Data is a REG_BINARY value with the file's data. Data is ignored if either NullFile or FileName is specified.
  • FileName: Creates a file that is a copy of a specified file. FileName is a REG_SZ value, set to the fully qualified path of the file to be copied.
  • NullFile: Creates an empty file. NullFile is not assigned a value. If NullFile is specified, the Data and FileName values are ignored.

And example create a new empty mpy file:

HKEY_CLASSES_ROOT
  (Default) = MyProgram.1
  MyProgram.1
   .myp
      ShellNew
         NullFile

To create a new file based on a specific template file:

HKEY_CLASSES_ROOT
   .myp
      (Default) = MyProgram.1
      MyProgram.1
         ShellNew
            FileName: REG_SZ = "%ProgramData%\Microsoft\Windows\Templates\MyNewTemplate.myp"
Ian Boyd
  • 21,642
  • 49
  • 139
  • 184
  • It's remarkable to me that you were the first to actually link to the official Microsoft Documentation. This was exactly what I needed, thanks. Ironic that it came from the lowest rated answer. – Chiramisu May 21 '23 at 05:35
2

Create a plain text file and add the following line to it:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.txt\ShellNew]
"NullFile"=""

Save the file and rename it's extention to a .reg file. E.g. "myNewItem.reg". Be sure that you renamed the extention and not only the file name like (myNewItem.reg.txt)

Double click the file and it will update your registry.

The next step, and that is very important, restart your computer directly. So DON'T try to open the content menu to see if it's already works! First restart you computer.

If you open the content menu to see if your amazing new item is already listed, the registry will be restored ...

Also try this program: http://sourceforge.net/projects/shellnewhandler/

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
Bnutoswa
  • 21
  • 1
1

The registry key:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew

cannot be changed to accomplish what is displayed or not displayed on the "New" context menu. If you change that value, it will be overridden by Explorer the next time you right click and bring up the "New" context menu. Try it and you will see what I mean.

Gaff
  • 18,569
  • 15
  • 57
  • 68
WoodyElf
  • 11
  • 1