Replacing notepad.exe in Windows 7

My idea is to create a supporter app that can piggyback on the Image File Execution registry entries to run EditPad correctly.

Note: You will have to restore your original Windows Notepad first, either through the error message that pops up, or by undoing the changes you made. Otherwise Windows may keep pestering you with the error message no matter what you try.

Tip: Notepad Replacer suggested by Dracs does something similar to what is below automatically. Try that first, unless you have reasons to avoid it such as the application being closed source. In which case, you can use the method below:

  1. Create a batch file with the following code. The batch file could be named Replacer.bat for example, and it could be placed anywhere such as EditPad's installation folder. (I assume EditPad is installed in the path given. If not, please change it.)

    SET NotepadTempVar=%*
    IF DEFINED NotepadTempVar SET NotepadTempVar=%NotepadTempVar:"C:\Windows\System32\notepad.exe"=%
    IF DEFINED NotepadTempVar SET NotepadTempVar=%NotepadTempVar:"C:\Windows\notepad.exe"=%
    IF DEFINED NotepadTempVar (
        FOR /F "tokens=*" %%A IN ("%NotepadTempVar%") DO SET NotepadTempVar=%%A
    )
    IF DEFINED NotepadTempVar (
        START "" "C:\Program Files\EditPad\EditPad.exe" "%NotepadTempVar%"
    ) ELSE (
        START "" "C:\Program Files\EditPad\EditPad.exe"
    )
    
    • CAUTION! It is necessary to have the empty string "" after START command, otherwise your system can go into an infinite loop of creating new Command Prompt windows.
    • You may have to verify the paths of the original Notepad in second and third lines to reflect your system. I found the paths to be same in both 32-bit and 64-bit Windows. The paths are case-insensitive but be careful to keep the quote marks around them.
    • On 64-bit Windows, you may need to add this extra line between the second and third lines:

      IF DEFINED NotepadTempVar SET NotepadTempVar=%NotepadTempVar:"C:\Windows\SysWOW64\notepad.exe"=%
      


  2. (optional) Use Batch To Exe Converter to compile the batch file to an executable program. Choose the "Invisible application" option.

    • If you do not wish to use Batch To Exe Converter, you may use another solution, or you may use the batch file itself for the following steps, instead of the compiled EXE file. However, if you use the batch file itself, you will see a momentary flashing of a command window before EditPad opens.

  3. Open Registry Editor by opening Start menu and searching for regedit (or using the Run command to run regedit).

  4. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

  5. If a key (folder in left pane) named notepad.exe does not exist inside Image File Execution Options, click Edit > New > Key and type notepad.exe as the new key's name. If it already exists, simply navigate to it.

  6. If an entry named Debugger (type REG_SZ) does not exist in the notepad.exe key (on right side), click Edit > New > String Value and type Debugger as the new entry's name.

  7. Double-click the entry named Debugger and enter the full qualified location and name of the EXE file generated by Batch To Exe Converter or the batch file if you did not use a compiler. Enclose the location in quotation marks.

    • For example, assuming you have stored the batch file in EditPad's program folder, the value of Debugger entry could be "C:\Program Files\EditPad\Replacer.bat" or "C:\Program Files\EditPad\Replacer.exe" where Replacer.bat is the batch file and Replacer.exe is the compiled EXE file obtained in step 2, if any.

  8. Test the setup by:

    • Opening Windows Notepad from Start Menu. EditPad should open instead.
    • Double-clicking on a text file or any file that's associated with Windows Notepad.
    • Testing other means you know should normally open Windows Notepad. They will very likely open EditPad instead.

If there are any problems, your paths in the batch file created in step 1 may not be correct. All other steps should be OK without any problem if you followed them correctly. Just verify and correct the paths in the batch file (and recompile EXE if needed).


Use the Image File Execution Options registry key.

  • Open regedit.exe as Administrator.
  • Navigate to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
  • Create a new key (folder) named notepad.exe
  • Create a new REG_SZ value named Debugger and set its value to your path to the Editpad.exe executable.

Done. This doesn't require modifying or removing the system's notepad.exe, but no matter how a program attempts to run it (just try double clicking the program from Explorer yourself), it will run EditPad.

If you're on 64-bit Windows and attempting to use a 32-bit program, make your changes in HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\ CurrentVersion\Image File Execution Options instead. (This info found on the Notepad2 - Replacing Windows Notepad page.)


I've done this on my computer using Notepad Replacer. It doesn't actually replace any files, but it does cause anything notepad would have done to use whatever program you choose. I haven't seen the original notepad since I installed it. The uninstall will also revert everything back easily.


I guess you also need to replace the notepad.exe file in %WINDIR%\winsxs\Backup but even this might not work properly - this has to do with Windows Resource Protection.