23

In Windows, if you right-click a .bat file, there's an "Edit" option, which opens the .bat file with notepad. How do I make Windows use Notepad++ instead?

Note that this is different from the question How do I set Notepad++ as the default editor?. In that question, user asks for a way to make Notepad++ the default opener for specific file types. This is not what I want here, since I expect that double-clicking on .bat files executes them.

a06e
  • 667
  • 3
  • 8
  • 23

2 Answers2

34

Change the program associated to the "Edit" verb for batch files:

  • Run RegEdit (as admin)
  • Navigate to HKEY_CLASSES_ROOT\batfile\shell\edit\command.
  • Modify the Default and change Value Data from %SystemRoot%\System32\NOTEPAD.EXE %1 to "C:\Program Files (x86)\Notepad++\notepad++.exe" "%1"
  • Close RegEdit.
  • Right-click -> "Edit" should now open batch files in NotePad++.

Note: You may have to adjust your path to Notepad++.exe if it resides in a different folder on your system.

Also note: This is a system-wide change.

Ƭᴇcʜιᴇ007
  • 111,883
  • 19
  • 201
  • 268
  • 2
    @MarkDuncan That's not really an alternative way to assign Notepad++ to the R-Click -> Edit menu entry. ;) – Ƭᴇcʜιᴇ007 Mar 06 '15 at 15:53
  • @Techie007 - No it's a quick and easy way without the need to rewrite any registry entries. I came here looking for the same solution(edit with another program) but then realised drag and drop would be sufficient. – t31os_ Mar 07 '15 at 11:49
  • Used to do this, but it's not working after win8. Is there any way to do this in win8 / win10 ? Btw I'm using notepad2. In win8/win10, it will show "windows can't open this type of file (.cmd / .bat)" – Til Jul 02 '17 at 08:48
  • @POW Just did it in Win 10. Working correctly, no errors. – user287352 Oct 27 '18 at 00:44
  • Never mind. Not working for Sublime Text 3. Sublime tries to open the folder and the file, presents it like it's a blank document, and asks you to save when you try to close it. – user287352 Oct 27 '18 at 00:49
  • 5
    I had to put quotation marks around `%1` to make it work with file paths with spaces: `"%1"` – Peter Wood Nov 21 '18 at 09:23
  • In 2022, notepad++ installs at `C:\Program Files\Notepad++\notepad++.exe` – blackboxlogic May 19 '22 at 18:25
2

If there are spaces in the filename being edited then double-quotes (") can be used to surround the argument. For example:

"C:\Program Files (x86)\Notepad++\notepad++.exe" "%1"
MrWhite
  • 2,848
  • 4
  • 32
  • 43
Johned
  • 21
  • 1