WinXP SP2 - How to Replace Notepad.exe

Installing SP2 brought back good ol' Notepad... what a shock. So I performed my usual steps for replacing Notepad with Florian Balmer's excellent Notepad2:

  • Create backup copy of c:\WINDOWS\notepad.exe
  • Change Explorer view options to show system files
  • In temporary folder: Prepare new notepad.exe.
  • Copy the EXE into the clipboard
  • Open folder C:\WINDOWS\system32\dllcache in Explorer
  • Ctrl-V, Backspace
  • Ctrl-V, Backspace
  • Ctrl-V, Backspace
  • Answer the "insert WinXP CD" dialog so Notepad won't be reverted to the original version.

But this time the dialog didn't appear and after a few seconds Notepad was changed back to the original (huh, what original? Didn't I just overwrite the version in the dllcache directory?).

Well, with SP2 there's a Notepad.exe in C:\WINDOWS\ServicePackFiles\i386 that will overwrite the replaced versions. After creating a backup copy of C:\WINDOWS\ServicePackFiles\i386\Notepad.exe and replacing this file with the new EXE I tried to replace Notepad again -- with success (even though no dialogs appeared).

Update 2007-07-31: My colleague Jens Schaller has posted a how-to for replacing Notepad on Windows Vista

18 Comments

  • Thanks! I was wondering why the old technique wasn't working.



  • notepad.exe is part of WFP (files protected by Windows File Protection). It's safer to update the WFP entries.

  • thanks heaps! I tried the old method with no success: however, still google hasn't indexed your page. I happened to come here after (desperately) searching for "SP2 dllcache"

  • sweet thx! that worked like a charm.

  • Thanks a bunch!! This made my afternoon more enjoyable.

  • Thanks for figuring this out. You would think after all these years that they would realize that their notepad sucks.

  • Doesn't work for me. Even if I write a batchfile to do the work fast.

  • How do I update the WFP entries? Please, step-by-step instructions. I'm not a programmer.

    Thanks a bunch.

  • > How do I update the WFP entries?

    I don't know (I didn't need to do it) -- maybe somebody else can help?

  • Tip on some systems (like one I worked on) the directory is C:\i386 and the file is something like notepad.ex_. Just replace that first

  • Tom: re: Notepad sucks

    Tom, I must disagree with that. Notepad is probably one of the best-written components of Windows. Small, fast and powerful, and the reason it is so is that the designer (whom I've spoken with via email)left out the bloat so common in MS products. Yes, there are many features that could be added to make it even more useful, as evidenced by the success of products like NoteTab and, of course, Notepad2, but do not take this to mean there was anything particularily wrong with the original.

  • The above methods didn't work for me, I didn't have a service pack directory. I finally found the location where notepad.exe was being cached in my version of Windows XP.

    c:\windows\prefetch\notepad.exe-?Huh?.pf

    Once this file is moved or removed, you can then replace the other instances of notepad.exe as stated above.

    Works very well, but requires that you have administrator priviledges, which is not always the case.

  • yup, what Tony said. I just renamed the two C:\Windows\Prefetch\notepad.exe-######.pf files and then did the regular replace. worked like a charp

  • my version of doit.cmd:
    -----------------------
    copy notepad2.exe C:\Windows2\System32\notepad.exe
    copy notepad2.exe C:\Windows2\notepad.exe
    copy notepad2.exe C:\WINDOWS2\ServicePackFiles\i386\notepad.exe
    copy notepad2.exe C:\WINDOWS2\$NtServicePackUninstall$\notepad.exe
    copy notepad2.exe C:\WINDOWS2\LastGood\notepad.exe
    copy notepad2.exe C:\WINDOWS2\system32\dllcache\notepad.exe
    ------------------------
    works fine.

  • @echo off
    setlocal enableextensions

    :: ReplaceNotepad.cmd
    :: Original: replace.cmd - replace a file that is under windows file protection

    ::- edit begin ----------------------------------------------------------------
    :: file in %systemroot%\system32 and/or %systemroot% to replace :
    set ef=notepad.exe
    :: backup file :
    set bf=%systemroot%\system32\original_%ef%
    :: WFP directory :
    set dc=%systemroot%\system32\dllcache
    :: Windows version; needed for %systemroot%\ServicePackFiles\%pr% :
    set pr=i386
    ::------------------------------------------------------------------ edit end -

    if not defined ef echo You must edit this script. & goto finish
    if not defined bf echo You must edit this script. & goto finish
    if not defined dc echo You must edit this script. & goto finish
    if not defined pr echo You must edit this script. & goto finish

    mode con lines=30 cols=85 & color 17 & cls
    echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    echo Replace / restore original "%ef%" in Windows 2000/XP/2003
    echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    echo.
    echo - You should have administrator priviledges when using this script.
    echo - Please close or minimize all other windows when using this script.
    echo.
    if not exist "%systemroot%\system32\%ef%" if not exist "%systemroot%\%ef%" (
    color 1e & cls & echo.
    echo ERROR: "%ef%" not found on your system.
    goto finish
    )
    if not exist "%dc%" (
    color 1e & cls & echo.
    echo ERROR: This script will only work if "%dc%"
    echo is the default directory of Windows File Protection [WFP].
    goto finish
    )
    if exist "%bf%" goto restore

    :replace
    echo.
    echo Do you want to replace original "%ef%" ?
    echo.
    echo.
    echo A backup file will be created if you choose yes:
    echo "%bf%"
    echo.
    echo.
    set /P yn= Press y (for yes) or n (for no), and press Enter:
    if /I not %yn%'==y' goto finish
    cls
    echo.
    echo Type the full path and name of the executable file you want
    echo to replace "%ef%" with, e.g.:
    echo C:\New Tools\NewPad\newpad.exe
    echo.
    echo Tip: You can also use drag'n'drop for this.
    echo.
    set /P rf= Type, and press Enter:
    set rf=%rf:"=%
    set rf=%rf: =/%
    set rf=%rf:/= %
    set rf="%rf%"
    if not exist %rf% (
    color 1e & cls & echo.
    echo ERROR: %rf% not found.
    goto finish
    )
    color 1e & cls
    echo.
    echo Ready to replace "%ef%" with:
    echo %rf%
    echo.
    echo.
    echo IMPORTANT - if you choose to do so:
    echo.
    echo Wait until the Windows File Protection message window appears:
    echo - for the 1st question click Cancel
    echo - for the 2nd question click Yes
    echo.
    echo.
    set /P yn= Press y (for yes) or n (for no), and press Enter:
    if /i not %yn%'==y' goto finish
    set go=1
    attrib -r -h -s %rf% > nul
    attrib -r -h -s "%systemroot%\%ef%" > nul
    attrib -r -h -s "%systemroot%\system32\%ef%" > nul
    if exist "%dc%\%ef%" attrib -r -h -s "%dc%\%ef%" > nul
    if exist "%systemroot%\servicepackfiles\%pr%\%ef%" attrib -r -h -s "%systemroot%\servicepackfiles\%pr%\%ef%" > nul
    if exist "%systemroot%\system32\%ef%" (
    copy /y /v "%systemroot%\system32\%ef%" "%bf%" > nul
    ) else (
    copy /y /v "%systemroot%\%ef%" "%bf%" > nul
    )
    if exist "%systemroot%\servicepackfiles\%pr%\%ef%" copy /y /v %rf% "%systemroot%\servicepackfiles\%pr%\%ef%" > nul
    if exist "%dc%\%ef%" copy /y /v %rf% "%dc%\%ef%" > nul
    copy /y /v %rf% "%systemroot%\system32\%ef%" > nul
    copy /y /v %rf% "%systemroot%\%ef%" > nul
    attrib +r "%bf%" > nul
    echo.
    echo.
    echo.
    echo AFTER you have answered, press any key to continue . . .
    pause > nul
    goto finish

    :restore
    echo.
    echo Do you want to restore original "%ef%" ?
    echo.
    echo.
    echo Backup file found:
    echo "%bf%"
    echo.
    echo.
    set /P yn= Press y (for yes) or n (for no), and press Enter:
    if /i not %yn%'==y' goto finish
    set go=1
    attrib -r -h -s "%bf%" > nul
    attrib -r -h -s "%systemroot%\%ef%" > nul
    attrib -r -h -s "%systemroot%\system32\%ef%" > nul
    if exist "%dc%\%ef%" attrib -r -h -s "%dc%\%ef%" > nul
    if exist "%systemroot%\servicepackfiles\%pr%\%ef%" attrib -r -h -s "%systemroot%\servicepackfiles\%pr%\%ef%" > nul
    if exist "%systemroot%\servicepackfiles\%pr%\%ef%" copy /y /v "%bf%" "%systemroot%\servicepackfiles\%pr%\%ef%" > nul
    if exist "%dc%\%ef%" copy /y /v "%bf%" "%dc%\%ef%" > nul
    copy /y /v "%bf%" "%systemroot%\system32\%ef%" > nul
    copy /y /v "%bf%" "%systemroot%\%ef%" > nul
    del "%bf%" > nul
    echo.
    echo.
    echo Done.
    goto finish

    :finish
    echo.
    echo.
    echo Press any key to exit . . .
    pause > nul
    if defined go start "..." "%ef%"
    color
    endlocal

  • On my XP Pro SP2 system dllcache *is* protected by WFP. So what I read about it being unprotected is wrong, as it seems.

    I found another copy of notepad.exe in c:\i386, the place where my PC vendor (Dell) placed the Windows installation file. I don't know if this is what finally brought up success, but after I had backuped and overwritten the file there it worked.

  • Sorry, but all these things are to complicated for me. And if you want go backward to the original notepad, it is complicated too.

    I use a very simple solution.

    Notepad from MS is essential for the system, but sometimes i prefer Notepad2 for editing files.

    So in XP exist an easy to use commandline-tool called FTYPE.

    Now i use this tool to associate some filetypes with Notepad2.

    Here my Script:

    @echo off
    :INF-files
    FTYPE inffile=%programfiles%\notepad2\notepad2.exe %1
    ASSOC .inf=inffile

    :INI-files
    FTYPE inifile=%programfiles%\notepad2\notepad2.exe %1
    ASSOC .ini=inifile

    :TEXT-files
    FTYPE txtfile=%programfiles%\notepad2\notepad2.exe %1
    ASSOC .txt=txtfile

    :NFO-files
    FTYPE nfofile=%programfiles%\notepad2\notepad2.exe %1
    ASSOC .nfo=nfofile

    :System-Informations-files SIF
    FTYPE siffile=%programfiles%\notepad2\notepad2.exe %1
    ASSOC .sif=siffile


    Works fine and is a simple batch-file.
    If you change the string "%programfiles%\notepad2\notepad2.exe" to "notepad.exe" (without the quotes) and safe the script to a different filename you can go back to the default Editor NOTEPAD from MS.

    greetz

    SkAvEnGeR

  • Sorry,

    in my last post i a small error.
    it must be %%1 at the end of the lines.

    Why.

    If u use the command FTYPE on the command-line its working with %1. But within BATCH-files it must be
    %%1 .

    Sorry. SkAvEnGeR

Comments have been disabled for this content.