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
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.