shahine.com/omar/

homepage | Send mail to the author(s) contact

yet another Microsoft blogger

# Friday, April 30, 2004

How to replace notepad.exe with notepad2.exe

Thanks to some great comments and a specific one from James I have now replaced notepade.exe with the vastly superior notepad2.exe and prevented Windows File Protection from replacing the new notepad.

Here are the steps (warning, process with care, no warranties etc):

Method 1

1) Rename Notepad2.exe to Notepad.exe
2) go to %windir%\system32
3) Rename Notepad.exe to NotepadX.exe
4) go to %windir%\system32\Restore
5) Turn off hide invisible files in Tools->Folder Options->View
6) Select filelist.xml and right click->Properties and uncheck Read-only
7) Edit the file
8) Add:

<REC>%windir%\notepad.exe</REC>

to:

<Exclude>
    <REC>%windir%\system.ini</REC>
    <REC>%windir%\tasks\desktop.ini</REC>
    <REC>%windir%\win.ini</REC>
    <REC>*:\AUTOEXEC.BAT</REC>
    <REC>*:\CONFIG.MSI</REC>
    <REC>*:\CONFIG.SYS</REC>
</Exclude>

9) copy the newly renamed notepad2.exe (now named notepad.exe) to %windir%\system32

note: it turns out that for some folks, this doesn't work. It did not work for me on my tablet pc. Thanks to Shakeel Mahate here is method #2.

Method 2

  1. Tools->Folder Options->View uncheck Hide protected operating system files. 
  2. rename Notepad2.exe notepad.exe 
  3. copy notepad.exe %windir%/system32\dllcache 
  4. copy notepad.exe %windir%/system32 
  5. A dialog will popup hit cancel 
  6. Recheck Hide protected operating system files in the Folder Options dialog box

The dllcache contains copies of the windows protected files. The dllcache isnt itself protected.

 

Sunday, May 02, 2004 1:32:41 AM (Pacific Daylight Time, UTC-07:00)
hi

I tried the above steps but windows still replaces the notepad.exe

any ideas?

TIA
ramesh
Ramesh
Sunday, May 02, 2004 12:12:22 PM (Pacific Daylight Time, UTC-07:00)
Yes, it seems that this method doesn't work on Windows Server 2003 or SP2 of XP. Are you running either? Or maybe it doesn't work for machines joined to a domain? Anyway, here are some other ways to go about it:

http://blogs.msdn.com/omars/archive/2004/04/30/124093.aspx#124619
Saturday, May 08, 2004 2:11:41 PM (Pacific Daylight Time, UTC-07:00)
I got Windows 2000. Neither the first or the second solution works. After some digging and guessing it turned out that if your intall path is available (ie. you got the i386 folder where Windows looks for it, usually CD, but I got tired of inserting on config changes, so I copied the whole i386 folder to C:\WINNT\Options and set the install path in registry to point to that, some OEMs do the same). Anyway when I did solutino#2 I never got setp#5. It went ahead and replaced it all with original Notepad.exe.

So for me
1. Tools->Folder Options->View uncheck Hide protected operating system files.
2. rename Notepad2.exe notepad.exe
3. Bork up the install path (I renamed C:\WINNT\Options\i386 to C:\WINNT\Options\ii386)
4. copy notepad.exe %windir%/system32\dllcache
5. copy notepad.exe %windir%/system32
6. A dialog will popup hit cancel (now it really will)
7. Unbork up the install path (I renamed C:\WINNT\Options\ii386 to C:\WINNT\Options\i386)
8. Recheck Hide protected operating system files in the Folder Options dialog box
Peter Lada
Tuesday, October 12, 2004 8:53:32 PM (Pacific Daylight Time, UTC-07:00)
It wouldn't work for me either. But I got it to work.

First Replace it in windows\ServicePackFiles, then dllcache, windows\system32, windows

But now that I think about it, I did all the above also, so I guess I also edited the filelist.xml.

But after doing all that I did get it to work.

Hope that helps someone out.

Brian
Monday, August 15, 2005 10:27:14 AM (Pacific Daylight Time, UTC-07:00)
Thanks Brian, your extra tip about the ServicePackFiles worked. I didn't do the filelist.xml bit so it does not seem to be neccesary.

I am on Windows XP with SP2.
Monday, October 27, 2008 2:46:08 AM (Pacific Daylight Time, UTC-07:00)
There is a cleaner way to do this that will leave Microsoft's Notepad executable untouched, and will probably remain working across operating system upgrades.

Save the following script as X:\ExecuteNotepadIFEO.js (after updating the path to Notepad2.exe in this script, using double-backslashes):

--- START SCRIPT ---

if( WScript.Arguments.length>0 )
{
var shell=new ActiveXObject("WScript.Shell");
var args="";
for( i=1; i<WScript.Arguments.Length; i++ )
{
args+=WScript.Arguments(i)+" ";
}

shell.Exec("X:\\notepad2.exe " + args);
}

--- END SCRIPT ---

Then save the following as Notepad2.reg (after making sure the path to the .js file exists:

--- START REG ---

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]
"Debugger"="wscript X:\\ExecuteNotepadIFEO.js"

--- END REG ---

Merge the .reg file (right-click).

And like magic, any attempt to execute anything named notepad.exe will start up notepad2. (The .js script is needed to strip off arguments that shouldn't be passed to notepad2).

Effective and none of this "copy-and-hope-for-the-best" stuff.
James
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview