Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Windows 7 - Add an item to 'new' context menu

This shows how to add items to the "New" dropdown menu. How about taking them away?

Also, I want to make a batch file that automates this. Like this:

@echo off
echo Enter you file extension
set /p ext=
copy con ext.reg
echo Windows Registry Editor Version 5.00 >> ext.reg
echo. >> ext.reg
echo [HKEY_CLASSES_ROOT\.%ext%\ShellNew] >> ext.reg
echo "NullFile"="" >> ext.reg
start /wait ext.reg
del ext.reg
echo Complete
exit
  1. Anything wrong with this, in general?
  2. Can you write to other types of non-text files like registry files with batch files?
  3. Please tell me the registry code for removing an item, so that I can add that.
  4. Most importantly, can a registry file interact with the user, like take in input and make a variable so I don't need a batch file at all?
share|improve this question

4 Answers 4

  1. I can't judge that, sorry.
  2. I don't know of a good way to write binary (non-text) files from a batch script.
  3. You can remove a registry key by using a .reg file as well. Simply by placing a hyphen before the key.

    To delete a registry key with a .reg file, put a hyphen (-) in front of the RegistryPath in the .reg file. For example, to delete the Test subkey from the following registry key: HKEY_LOCAL_MACHINE\Software
    put a hyphen in front of the following registry key in the .reg file: HKEY_LOCAL_MACHINE\Software\Test
    The following example has a .reg file that can perform this task.
    [
    -HKEY_LOCAL_MACHINE\Software\Test
    ]

  4. A registry file is only used to manipulate the registry hive. No user interaction (other than a confirmation prompt) is supported in the process to my knowledge.

share|improve this answer
    
how about the batch file? its the same idea, adding the delete –  Jam35B0nd. Mar 1 '12 at 13:54
  1. Absolutely not, just be sure to back up the registry before you go hog wild.
  2. Not very easily. You'd be much better off simply writing a .reg file, which can handle just about everything you need.
  3. In a .reg file, simply add a '-' (minus) after the opening bracket of the item to be removed. See example below.
  4. Nope. Perhaps write a script (or batch file) to automate the generation of a .reg file, which can then be invoked.

Here are the contents of the registry file that I use to eliminate many of the common new template items in Windows 7. Feel free to use it as a basis for your own. REMEMBER TO BACK UP THE REGISTRY FIRST.

    Windows Registry Editor Version 5.00
;Remove everything from the "New" menu other than folder and .txt

; MFC Trace file
[-HKEY_CLASSES_ROOT\.trc\ShellNew]

;Briefcase
[-HKEY_CLASSES_ROOT\Briefcase\ShellNew\Config]
[-HKEY_CLASSES_ROOT\Briefcase\ShellNew]

; Bitmap
[-HKEY_CLASSES_ROOT\.bmp\ShellNew]

; Contact
[-HKEY_CLASSES_ROOT\.contact\ShellNew]

; Skype Contact
[-HKEY_CLASSES_ROOT\.skype\Skype.Content\ShellNew]

; Link
[-HKEY_CLASSES_ROOT\.lnk\ShellNew]

; Microsoft Word Documents
[-HKEY_CLASSES_ROOT\.doc\Word.Document.8\ShellNew]
[-HKEY_CLASSES_ROOT\.dochtml\wordhtmlfile\ShellNew]
[-HKEY_CLASSES_ROOT\.docm\Word.DocumentMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.docx\Word.Document.12\ShellNew]
[-HKEY_CLASSES_ROOT\.docxml\wordxmlfile\ShellNew]
[-HKEY_CLASSES_ROOT\.dot\Word.Template.8\ShellNew]
[-HKEY_CLASSES_ROOT\.dothtml\wordhtmltemplate\ShellNew]
[-HKEY_CLASSES_ROOT\.dotm\Word.TemplateMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.dotx\Word.Template.12\ShellNew]
[-HKEY_CLASSES_ROOT\.rtf\Word.RTF.8\ShellNew]
[-HKEY_CLASSES_ROOT\.wbk\Word.Backup.8\ShellNew]
[-HKEY_CLASSES_ROOT\.wiz\Word.Wizard.8\ShellNew]
[-HKEY_CLASSES_ROOT\.wll\Word.Addin.8\ShellNew]
[-HKEY_CLASSES_ROOT\.rtf\ShellNew]

; Microsoft Excel Documents
[-HKEY_CLASSES_ROOT\.csv\Excel.CSV\ShellNew]
[-HKEY_CLASSES_ROOT\.oft\Outlook.File.oft.14\ShellNew]
[-HKEY_CLASSES_ROOT\.slk\Excel.SLK\ShellNew]
[-HKEY_CLASSES_ROOT\.xla\Excel.Addin\ShellNew]
[-HKEY_CLASSES_ROOT\.xlam\Excel.AddInMacroEnabled\ShellNew]
[-HKEY_CLASSES_ROOT\.xld\Excel.Dialog\ShellNew]
[-HKEY_CLASSES_ROOT\.xlk\Excel.Backup\ShellNew]
[-HKEY_CLASSES_ROOT\.xll\Excel.XLL\ShellNew]
[-HKEY_CLASSES_ROOT\.xlm\Excel.Macrosheet\ShellNew]
[-HKEY_CLASSES_ROOT\.xlsb\Excel.SheetBinaryMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.xlshtml\Excelhtmlfile\ShellNew]
[-HKEY_CLASSES_ROOT\.xlsm\Excel.SheetMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.xlsx\Excel.Sheet.12\ShellNew]
[-HKEY_CLASSES_ROOT\.xlt\Excel.Template.8\ShellNew]
[-HKEY_CLASSES_ROOT\.xlthtml\Excelhtmltemplate\ShellNew]
[-HKEY_CLASSES_ROOT\.xltm\Excel.TemplateMacroEnabled\ShellNew]
[-HKEY_CLASSES_ROOT\.xltx\Excel.Template\ShellNew]
[-HKEY_CLASSES_ROOT\.xlw\Excel.Workspace\ShellNew]
[-HKEY_CLASSES_ROOT\.xls\Excel.Sheet.8\ShellNew]

; Microsoft Powerpoint Documents
[-HKEY_CLASSES_ROOT\.pot\PowerPoint.Template.8\ShellNew]
[-HKEY_CLASSES_ROOT\.pothtml\powerpointhtmltemplate\ShellNew]
[-HKEY_CLASSES_ROOT\.potm\PowerPoint.TemplateMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.potx\PowerPoint.Template.12\ShellNew]
[-HKEY_CLASSES_ROOT\.ppa\PowerPoint.Addin.8\ShellNew]
[-HKEY_CLASSES_ROOT\.ppam\PowerPoint.Addin.12\ShellNew]
[-HKEY_CLASSES_ROOT\.pps\PowerPoint.SlideShow.8\ShellNew]
[-HKEY_CLASSES_ROOT\.ppsm\PowerPoint.SlideShowMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.ppsx\PowerPoint.SlideShow.12\ShellNew]
[-HKEY_CLASSES_ROOT\.ppt\PowerPoint.Show.8\ShellNew]
[-HKEY_CLASSES_ROOT\.ppthtml\powerpointhtmlfile\ShellNew]
[-HKEY_CLASSES_ROOT\.pptm\PowerPoint.ShowMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.pptx\PowerPoint.Show.12\ShellNew]
[-HKEY_CLASSES_ROOT\.pptxml\powerpointxmlfile\ShellNew]
[-HKEY_CLASSES_ROOT\.pwz\PowerPoint.Wizard.8\ShellNew]
[-HKEY_CLASSES_ROOT\.sldm\PowerPoint.SlideMacroEnabled.12\ShellNew]
[-HKEY_CLASSES_ROOT\.sldx\PowerPoint.Slide.12\ShellNew]

; Microsoft Outlook entries
[-HKEY_CLASSES_ROOT\.msg\Outlook.File.msg.14\ShellNew]
[-HKEY_CLASSES_ROOT\.vcf\Outlook.File.vcf.14\ShellNew]
[-HKEY_CLASSES_ROOT\.hol\Outlook.File.hol.14\ShellNew]
[-HKEY_CLASSES_ROOT\.ics\Outlook.File.ics.14\ShellNew]
[-HKEY_CLASSES_ROOT\.pst\Outlook.File.pst.14\ShellNew]
[-HKEY_CLASSES_ROOT\.vcs\Outlook.File.vcs.14\ShellNew]

; Microsoft Visio Drawing
[-HKEY_CLASSES_ROOT\.vdx\Visio.Drawing.11\ShellNew]
[-HKEY_CLASSES_ROOT\.vsd\Visio.Drawing.11\ShellNew]
[-HKEY_CLASSES_ROOT\.vss\Visio.Stencil.11\ShellNew]
[-HKEY_CLASSES_ROOT\.vst\Visio.Template.11\ShellNew]
[-HKEY_CLASSES_ROOT\.vsw\Visio.Workspace.11\ShellNew]
[-HKEY_CLASSES_ROOT\.vsx\Visio.Stencil.11\ShellNew]
[-HKEY_CLASSES_ROOT\.vtx\Visio.Template.11\ShellNew]

; Microsoft Project Document
[-HKEY_CLASSES_ROOT\.mpp\MSProject.Project.9\ShellNew]
[-HKEY_CLASSES_ROOT\.mpt\MSProject.Template\ShellNew]
[-HKEY_CLASSES_ROOT\.mpw\MSProject.Workspace\ShellNew]
[-HKEY_CLASSES_ROOT\.mpx\MSProject.MPX\ShellNew]
[-HKEY_CLASSES_ROOT\.mpd\MSProject.MPD\ShellNew]
[-HKEY_CLASSES_ROOT\.mpf\MediaPackageFile\ShellNew]

; Microsoft OneNote
[-HKEY_CLASSES_ROOT\.one\OneNote.Section.1\ShellNew]
[-HKEY_CLASSES_ROOT\.onepkg\OneNote.Package\ShellNew]
[-HKEY_CLASSES_ROOT\.onetoc\OneNote.TableOfContents\ShellNew]
[-HKEY_CLASSES_ROOT\.onetoc2\OneNote.TableOfContents.12\ShellNew]

; Microsoft Graph
[-HKEY_CLASSES_ROOT\.gra\MSGraph.Chart.8\ShellNew]

; Microsoft Office Theme
[-HKEY_CLASSES_ROOT\.thmx\OfficeTheme.12\ShellNew]

; Microsoft Office List Shortcut
[-HKEY_CLASSES_ROOT\.ols\OfficeListShortcut\ShellNew]

; Microsoft Journal Entry
[-HKEY_CLASSES_ROOT\.jnt\jntfile\ShellNew]

; Microsoft Publisher
[-HKEY_CLASSES_ROOT\.pub\Publisher.Document.14\ShellNew]

; PCB
[-HKEY_CLASSES_ROOT\.pcb\PCBFile\ShellNew]

; PDX
[-HKEY_CLASSES_ROOT\.pdx\PDXFileType\ShellNew]

; UMP Profile
[-HKEY_CLASSES_ROOT\.umprofile\umprofilefile\ShellNew]

; UMS Shortcut
[-HKEY_CLASSES_ROOT\.umshortcut\umshortcutfile\ShellNew]

; Zip
[-HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew]
share|improve this answer
    
I get the whole reg part, thanks. I just want to make it easier and interactive (for my family or something) with the batch file. How come I can't write to a reg file? I know it's binary, but isn't everything? –  Jam35B0nd. Mar 2 '12 at 12:18
    
You can write a reg file. You just can't write an interactive reg file. They don't support any kind of user input. –  Fopedush Mar 5 '12 at 21:08
    
so that batch file writing to the reg file part is good? –  Jam35B0nd. Mar 14 '12 at 5:09
    
Yes. ``````````` –  Fopedush Mar 14 '12 at 14:50

Just remove this line to get it working:

copy con ext.reg
share|improve this answer
1  
Can you add some explanation as to why this would fix the problem. –  ChrisF Mar 9 '13 at 17:34

actually you can programmatically write/read/interact with the registry...

[usage, @ cmd] reg /?

to delete (via reg /? |clip :)

REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

KeyName [\Machine]FullKey Machine Name of remote machine - omitting defaults to the current machine. Only HKLM and HKU are available on remote machines. FullKey ROOTKEY\SubKey ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey The full name of a registry key under the selected ROOTKEY.

ValueName The value name, under the selected Key, to delete. When omitted, all subkeys and values under the Key are deleted.

/ve delete the value of empty value name (Default).

/va delete all values under this key.

/f Forces the deletion without prompt.

Examples:

REG DELETE HKLM\Software\MyCo\MyApp\Timeout Deletes the registry key Timeout and its all subkeys and values

REG DELETE \ZODIAC\HKLM\Software\MyCo /v MTU Deletes the registry value MTU under MyCo on ZODIAC

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.