Tuesday, July 19, 2005

Replacing Notepad on Windows

A fast lightweight text editor is always nice to have, but on Windows, Notepad falls far short. There are a few light text editors for Windows that are just as light and fast as Notepad, but include features that frequently come in handy.

Metapad is my Notepad replacement of choice. A few notable features it offers that Notepad lacks follows (with a full list on the Metapad site).
  • URL's are clickable links
  • Doesn't botch up non-Windows text files (some Unix and Mac file types are problematic in Notepad)
  • Line and column count
  • No file size limit
Actually getting Notepad replaced is a major pain. File associations, context menu replacements, etc. etc. It's much easier to just replace notepad.exe. But Microsoft makes that difficult too!

notepad.exe is located in C:\Windows\system32. But if you delete it, or rename it, as soon as you do Windows will replace it. This is a "feature" of Windows File Protection. When you do this, you'll see a message like the following in your Event Viewer:

Event Type: Information
Event Source: Windows File Protection
Event Category: None
Event ID: 64002
Date: 7/19/2005
Time: 5:06:58 PM
User: N/A
Computer: CMB
Description:
File replacement was attempted on the protected system file notepad.exe. This file was restored to the original version to maintain system stability. The file version of the system file is 5.1.2600.2180.

To get around this, I run a batch file with the following three lines. The batch file lives in the same directory as the downloaded metapad.exe.

copy metapad.exe %windir%\system32\dllcache\notepad.exe

copy metapad.exe %windir%\system32\notepad.exe

copy metapad.exe %windir%\notepad.exe


The dllcache directory is where Windows File Protection keeps its files used to replace protected files if they become modified. Windows obviously doesn't protect the dllcache the way it does the rest of the files, so the above seems to work fine (at least for me). I've used it on Windows 2000 Server, XP Pro, and Server 2003 without a hitch.

11 Comments:

Anonymous Jeroen Visser said...

Hi Chris,

Stubled upon your site via m0n0wall mailinglist. Thnx for being such a GREAT help on that list by the way.

Try Notepad++ instead of mpad.
http://notepad-plus.sourceforge.net/uk/site.htm

I love this notepad replacement.

4:01 PM  
Blogger badevlad said...

I think, BDV Notepad is much better for regular users, and have a lot of unique functions. All my friends use it for a long time.
Here it is: http://www.badevlad.com/bdvnotepad_en.htm

5:14 AM  
Anonymous Anonymous said...

Chris,

Similarly stumbled upon your blog as jeroen did - thanks from me, too.

There's another (easier) way to replace notepad.exe...

Assuming MetaPad is at C:\Program Files\MetaPad\MetaPad.exe, create a registry key called notepad.exe in
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\

Give it a new String value, of name debugger and data of C:\Program Files\MetaPad\MetaPad.exe.

Double click any associated text file and it should open directly in MetaPad.

I came across this technique using Sysinternals' excellent autoruns Process Explorer tool (a more advanced Task Manager). It has an option 'Replace Task Manager' which causes it to be launched instead of TaskMgr.exe, however you tried to open TaskMgr (CTRL+SHIFT+ESC, CTRL+ALT+DEL, then Task Manager etc). www.sysinternals.com.

Sysinternals implement this substitution in exactly the way described above, and for MetaPad, it should also be immune to service packs and patches, which your method may not be.

I'm a TextPad devotee, so I only know that this works with TextPad - but it should be the same for Meta.

Best wishes,
S

4:52 PM  
Blogger Shellie said...

I'm a TextPad man myself.

8:54 PM  
Anonymous Anonymous said...

Using the Image File Execution Options registry tweak to replace notepad isn't really the correct thing to do. What will really happen:

If, say, you add a key called notepad.exe, with Debugger="SomeTextEditor.exe", this is the result:
SomeTextEditor.exe Notepad.exe Filename.whatever

So, SomeTextEditor will try to open Notepad.exe and will screw up whatever parameters come afterward (the filename), IF there are spaces in the file's path. (eg, "c:\Program Files\SomeFile.ini")

If I replace notepad.exe in this manner, with PSPad.exe, this is what PSPad does when I double click on "C:\Program Files\PSPad Editor\online.ini":

It opens 5 file tabs
1. notepad.exe
2. Program
3. Files
4. (x86)\PSPad
5. Editor\online.ini

The Debugger line is added IN FRONT of what would normally run (in this case, notepad.exe), not IN PLACE OF.

6:08 AM  
Anonymous CuriousG said...

I've used AkelPad and it is very small and still being updated. Latest version is 4.02 which was just released August 18th, 2008. I realize you posted this a few years ago but I just stumbled on this and it does the notepad replacement for you. There are even plug-ins if you decide that the stock program doesn't have what you need.

12:18 AM  
Anonymous Anonymous said...

Before you run the batch file above don't forget to delete the corresponding file from the Windows/Prefetch folder first.

3:40 PM  
Blogger Jan said...

Here is a complete batch, working with:
-Win XP 32bit SP0, SP1, SP2, SP3

The batch uses the better method than just overwrite the notepad. It sets Notepad to the exception-list in Windows and uses a replacement. Thats the best soltuion.

Automatic batch: (1mb)
http://rapidshare.com/files/164587454/Notepad_Replace__XP_SP1_SP2_SP3_.rar

To replace Notepat with Notepad2 execute "replace notepad.bat"
To restore original Notepad execute "restore notepad.bat"

6:56 AM  
Anonymous Anonymous said...

> Jan said...
> [...]
> Thats the best soltuion.

It might be, if the xml for the exception were correctly formed and the metapad executable corresponded to Alexander's latest version...

4:06 PM  
Anonymous selyb said...

Here is a tutorial to replace notepad without modifying system files or permissions and works on all versions of NT
http://www.vistax64.com/tutorials/244527-programs-replace-system-program-without-modifying-system-files-permissions.html

5:48 PM  
Anonymous Anonymous said...

Have you tried jEdit? Tons of features for programmers, hundreds of plugins for different tasks, and it's completely cross-platform.

1:41 AM  

Post a Comment

<< Home