Subscribe to How-To Geek

Recommended: Click Here to Run a Free Scan for Common PC Errors   [Sponsored Link]

Add "Open with Notepad" to the Context Menu for All Files

The default method of opening unknown files forces you to go through a list of known applications and is generally a pain to deal with. That's why I like to have a context menu option for "Open with Notepad" so that I can quickly open up files without having to go through a lot of trouble.

This registry hack is nothing new, it's been around forever… think of this as a refresher course. Also note that you can use this same technique to substitute any other application that you'd like by adjusting the path in the registry to point to the different editor.

image

Manual Registry Hack

Open regedit.exe through the start menu search or run box, and then browse down to the following key:

HKEY_CLASSES_ROOT\*\shell

image

Right-click on "shell" and choose to create a new key, calling it "Open with Notepad". Create a new key below that one called "command". Double-click on the (Default) value in the right-hand pane and enter in the following:

notepad.exe %1

The change should take effect immediately… just right-click on any file and you'll see the next menu entry.

Download Registry Hack

Just download, extract and double-click on the OpenWithNotepad.reg file to enter the information into the registry. There's also an uninstall script included.

Download OpenWithNotepad registry hack

The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 02/4/08 and tagged with: Windows Vista, Vista Tips & Tweaks

Comments (40)

  1. darkhelmet

    Hehe…why you want to use that hack of a text editor anyway :P
    Grab Notepad++, and then just tell it to open everything :D

  2. The Geek

    Totally agree… you can see in the screenshot that I use UltraEdit =)

    I'm sure this will still be useful for somebody though, if only to show how to do it.

  3. Gene Thomas

    Or, you could download the notepad replacement, notepad++. Its installation offers the option of adding it to the context menu.

  4. nants

    Um. What am I missing? Why the registry hack? Simpler to add a shortcut to one's SendTo folder, yes?

    1. Open C:\Documents and Settings\MyLoginName\SendTo folder
    2. Right-click, choose "New shortcut"
    3. Type in Notepad.exe (no path needed)

    VoilĂ !

  5. The Geek

    @nants

    You are absolutely correct, that method works perfectly… however I've always found the SendTo to be much slower than this method. Perhaps I should look into that…

    Note that you could also create a notepad shortcut in quick launch or desktop and drag and drop the file onto it.

  6. nants

    The Geek, Interesting to note about speed. I like SendTo because it's not beyond any capable user, and it's useful for many things. I've added shortcuts to register and unregister DLLs, for example. In any case, I appreciate the extra registry tidbit. Thanks.

  7. Jordan

    Does anyone know if this works for Vista?

    As for those who prefer an alternate editor, (I'm a huge fan of EditPad lite) I'm sure this will work for you with an alternate file system path.

  8. dner

    Did not work from HKEY_CLASSES_ROOT\*\shell…

    Did work from HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell

    Same instructions

  9. dner

    Also note that changing the value for Default for the Open with Notepad key changes the text that appears in the context menu.

  10. jorsch

    What about adding separators to the items on the Context list? I have been searching for a way to do that forever and have not been successful.

  11. EnOne

    This seems like a good way to add to the context menu. How do you remove items from the context menu. WinZip and McAfee come to mind.

  12. The Geek

    @EnOne

    With WinZip you can go into the configuration settings and turn off those context menu entries. This works for most well-behaved software as well.

    For McAfee, it's a little more of a pain… Usually you can find their entries in a similar registry spot, but you might have to use ShellExView or one of those tools to remove the shell extension. I need to look into this, would make a great article topic.

  13. The Geek

    @Jordan

    This does work for Vista… the screenshots are from my Vista machine, in fact =)

    @jorsch

    That's a really good question, something I've wanted for a long time but haven't found a solution. I'm pretty sure you'd need a third-party shell extension, but I suppose there's a possibility there's a registry hack for it.

  14. Johnboy

    @EnOne
    h**p://www.hace.us-inc.com/mmm.shtml

    There is a free & pay version…for XP only.

    This is an elegant solution, I've used it for years.

  15. Mario Grgic

    Why bother with all this. Why not just add a shortcut to notepad.exe in "Send To" folder. Then just right click on any file and send it to notepad, effectively opening the file in notepad.

    While you are at it download Notepad++ (a better notepad), or if you are a programmer, learn VIM (it will pay dividends for the rest of your life).

  16. jd2066

    Nice tip.
    Oddly enough the idea of adding notepad* to the context menu in Windows didn't occur to me before even though I use it all the time.
    Also I found adding the command to the HKCR\AllFilesystemObjects key instead of HKCR\* worked better on my computer as it appears the * key also adds the menu item to special folders like Computer and Network.

    * That would be metapad for my computer and notepad for other ones I use.

  17. The Geek

    @jd2066

    Are you on Windows XP? On my Windows Vista box I don't see that.

  18. jd2066

    I'm using Windows Vista. I guess something must be broken on my install as a quick search online shows the HKCR\* key is suppose to to be files only and not folders.

  19. jd2066

    It also appears using this tip with AllFilesystemObjects will make all folders in explorer open with notepad.
    I guess I'll just stick with * and hope that the notepad entry displaying on folders is a bug that will be patched.

  20. jd2066

    I just did it with the * key and everything works.
    I think what happened was I made the mistake of thinking that since PowerCMD used that key and displayed for special folders that it meant I would have this problem with notepad too and didn't even try the * key. I think PowerCMD must be using another key to display on folders.
    Sorry about the waste of comment space. I would delete my extra posts and the part in my first post about the AllFilesystemObjects if I could.

  21. Michael

    Worked okay on my computer (XP) and my laptop (Vista). Thanks for your advise!

  22. B

    you guys need to go out more often…

  23. TJ

    You might want to quote the %1 -> "%1″ The Open With.. didn't work with paths with spaces in it without it.

  24. Johny

    Has any one gotten this to work with XP?

  25. Johny

    Never mind. I got it to work. In XP the shell key does not already exist under *. So I had to first create the key:

    HKEY_CLASSES_ROOT\*\shell

    Everything else worked the same way. Thanks a lot.

  26. Johny

    I was hoping to use this to "send" multiple files at once to a program for processing. Unfortunately, when attempting to send more than one file, it makes a different call to the application for each file, resulting in several instances of the program.

    I don't know if I am explaining this well. I want to be able to send several files to a single instance of a program, like you can do with Winzip for example. I have a feeling that this is a lot more involved, but if any one know of a simple way to do this I would be very appreciative.

  27. jd2066

    You can try using the Program Fast Explorer at http://thesoftpro.tripod.com/downloads/fe/
    Under Vista you need to run it's configuration program as an Administrator. I just tested it and it crashed saving settings when I didn't do that.
    Just go to the "Submenu Items" tab and add your program. Despite it's name you don't have to put the item under a submenu, just click click Item and Add item.
    That tab configures entries with it's shell extension that will launch programs how you want. Unfortunately, since that uses the command line there is a length limit for it. For one path I used with it the max files I could use it to open was about 50 I think.

  28. Johny

    Thanks for the tip. But, from your description it sounds like there may be no advantage to just using the plain old "Send to" method. It is also limited to a certain number of characters it can send. So if there are a lot of file, or if the path to the files is deep, it complains with some bogus message about not being able to access the files. But, thanks any way. Fortunately in Linux I don't have that problem with KDE Service Menus (the "Send to" equivalent ;) .

  29. jd2066

    Well there is the advantage of launching a program with the selected files instead of one application instance for each file. It just has a limit due to the command line limit.
    I think the KDE Service Menus also use the command line for this.
    It just works better because a longer command line length limit.
    If I understand right the max command line is 8191 characters in Windows and in Linux it is 131072 characters.
    Those programs may have a shorter limit though.
    I'll have write some test scripts to see if the limits are correct.

    Info from:
    http://support.microsoft.com/kb/830473/en-us
    http://www.in-ulm.de/~mascheck/various/argmax/

  30. Johny

    Wow, big difference between 131K and 8K. Thanks for the info.

  31. jd2066

    Ok. I just did some tests.
    With some test commands on Linux with bash it appears the number I found is correct.
    With a test script on Windows Vista with Fast Explorer I got a max command line of 32733 characters and with that I could send about 266 files to my test script.
    So what I listed of 8191 characters above only applied to commands typed in the command prompt.
    When I could only send 50 files before I had an older version of Fast Explorer and used Windows XP.
    One of them had a lower limit I guess.
    So the difference is actually about 131K and 32K.
    Still quite a difference in command line limits between Windows and Linux.

  32. GoodBytes

    This is cool, but I wonder how to add an icon next to the item i the context menu, like in PowerArchiver, you have icons of the program on each of its item. Is it possible, or is some super complicated windows hack?

  33. jd2066

    You can try Fast Explorer (link in above post).
    You can add items with an icon beside just like those archive programs do when you use it's "Submenu Items" tab (Badly named though as it's not just for submenus). It's static items tab just uses the registry like this article lists.

  34. GoodBytes

    Well I ask to know how to do it manually, as I am making a small software, and I would like to have the icons next to my context menu items.

  35. jd2066

    In that case you would need to write a context menu handler that displays the item with an icon.
    There are some tutorials online on how to write them.
    One such tutorial is at http://www.codeproject.com/KB/.....uide2.aspx

  36. Gene Thomas

    You might try abiword instead of notepad, or notepad++. It is a free, fairly complete, but very compact word processor that loads very quickly due to its compactness. On a new, fast machine such as mine, it loads very fast.

  37. GoodBytes

    Thanks, jd2066

  38. Matthew Delisle

    I made a little program if you don't like messing the registry.

    http://mattdelisle.net/?p=6

  39. Floroskop

    Hello!
    I think this try.

  40. abhishek

    adding entry for the notepad is good…but i would prefer notepad++ which automatically adds an entry in the right click menu.


Leave a Comment




Leave your friendly comment here. If you have a computer help question, leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.