Replacing Notepad with PN via Image File Execution Options

A user opened a bug asking me to look into a new way of replacing notepad.exe with PN. Previous methods have involved a small program that pretends to be notepad.exe but actually launches PN. This has a number of problems:

  1. Replacing system files like notepad.exe on modern Windows is much harder due to System File Protection
  2. Many tools expect notepad.exe to hang around until you save the file, meaning they can pick up the changes when you’re done. The notepad.exe replacement exited having launched PN so didn’t work well with this.

The new technique involves using something called Image File Execution Options. This is a set of registry settings used to make Windows run a debugger automatically when a program is launched. We can piggyback on this to run PN instead of notepad when it’s launched.


1. Create this Registry Key:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
Image File Execution Options\notepad.exe

2. Add a string value called “Debugger”, set the value to:

c:\Program Files\Programmer's Notepad\pn.exe --allowmulti -z

The –allowmulti deals with the second problem listed above, making sure that even if PN is already running a new instance is started – this means that the calling process can wait for PN to exit. The –z tells PN to ignore the next parameter, which when using Image File Execution Options is the process name that we’re replacing – the full path to notepad.exe in this case.

This is only available in the lastest 2.1 testing release for now (1117), but should be ready to try. Let me know how you get on.


Note that if you’re on 64-bit Windows you’ll need the following Registry Key instead:

HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\
CurrentVersion\Image File Execution Options


  1. Hi Simon:

    Any chance that an upcoming release will combine the current 2.0.10 Smart Highlight feature with the Multiple Selections and Block Typing features in 2.1 testing release.

    Thanks for a great program!


  2. This should be working right now, I have both multiple selections and the smart highlight working for me in 1117 – are you seeing problems with it?

  3. Sorry, I wasn’t very clear in my comments.

    Here is what I’m trying to achieve:
    1. Highlight all instances of a word with the Smart Highlight feature
    2. Convert it to a Multiple Selection (with a right click? or a keyboard shortcut ?)
    3. Edit the multiple selection using the Block Typing feature

    That would be awesome!

  4. Also all the individual features (Smart Highlight, Multiple Selection and Block Typing) work properly for me in 1177. I’m just trying to figure out if I can combine them. I guess I’m just looking for a “Select All Highlighted” context menu item…

  5. I’ve released a new plugin for PN 2.1 which does what you’re looking for, let me know how you get on!

    New Development Build

  6. the -z option does not work, I try to convert that to write.exe (wordpad), and everytime i try to open notepad, it would still give me a warning message. How do I know why -z arg would work?

  7. Thanks for PN 2.1. You rock!