4

I'd like to change my default notepad program from notepad2 to notepad++ (but my question is more complicated than just that so please don't stop reading!) When making the change from notepad to notepad2 a few months ago, I wasn't aware of symbolic links so I resorted to manually replacing the executables themselves (see footnote for more detail on how to do it without symlinks). Now that I've seen the light, I'd like to use symlinks for this purpose as it would be (really) good to not have to update the executables manually whenever a new version of notepad++ is released.

However, Windows is foiling my plans! Based on the following three observations, we can conclude that Windows 7 will automatically redirect (i.e., hijack!) any file or symbolic link named notepad.exe that's located anywhere outside of the three default folders:

  • If we create a symbolic link named notepad++.exe that's located in C:\ (i.e., outside of the three default folders) and that links to the original Notepad++ executable --> then double-clicking the symlink in Windows Explorer results in Notepad++ opening (great!)
  • But if we create try the same thing except give our symlink the name notepad.exe (i.e., this link is also hard-linked back to the Notepad++ executable) --> double-clicking it results in Notepad2 opening (wat)
  • Moreover, if we create a copy of the Notepad++ executable (i.e., not a symlink but a copy of the .exe file itself) and rename it to notepad.exe --> double-clicking this file will also open up Notepad2 (wat)

As you can see, my goal was to test the symlink in a separate folder prior to making symlinks in the correct system folders. My question has two parts:

  • Is there any special process for making the change (described in the footnote) using symlinks given the behavior described above?
  • Is there anyway to disable the OS's behavior for the notepad.exe moniker?

Footnote: For context, changing the default Notepad application in Windows 7 involves swapping out the notepad.exe executable in three folders: C:\Windows\, C:\Windows\System32 and, if you have a 64-bit system, C:\Windows\SysWOW64\. (When making the change for the first time, we also need to go through some steps to give permissions but that's not relevant here.)

  • Good question. I used to replace notepad.exe with my favorite editor, but now I just change the file associations. Seems to work well. – RockPaperLizard Oct 19 '14 at 6:05
  • Um, why don't you just use the registry hack? That's what Notepad2 installer does to replace Windows notepad. Very clean solution and you can run "notepad.exe" from anywhere even executing the original notepad.exe and it will always launch Notepad2 (or Notepad++ if you configured so). Cleaner than hard replacements and symbolic links. – ADTC Oct 20 '14 at 1:29
  • It uses "Image File Execution Options" and it works by making NP2 or NP++ the debugger for NP. For Notepad2, instructions here. For Notepad++ ready-to-use reg file here (It's safe; you can check in NP). – ADTC Oct 20 '14 at 1:43
  • It's not an exact duplicate, but you may want to see the related question "How do I replace Notepad in Windows 7?" – Stevoisiak May 11 '17 at 4:23
1

Okay figured it out; this is my first time answering my own question!

So as to make this a helpful standalone post, I'll include 'from scratch' instructions on how to replace notepad. Here we go!

  1. "Won't you back that app up?"

    • There are three relevant folders in which we'll need to update notepad.exe (two if you have 32-bit Windows 7): C:\Windows\, C:\Windows\System32 and, if you have a 64-bit system, C:\SysWOW64\
    • Let's back-up the existing versions of Notepad. In a new folder named Notepad Backup (or something more creative, if you prefer), copy and paste the notepad.exe executable from each of the relevant folders (listed above). I've renamed mine; for example, the executable originally in C:\Windows\ is named notepad-CWindows.exe.BAK in my backup folder.
  2. "Throw the old app to the curb"

    • First we need to give ourselves the right permissions in the relevant folders. We can do the following in each instance of notepad.exe (i.e., we'll have to do it twice in Windows 7 32-bit and three times in Windows 7 64-bit):

      (i) right-click on notepad.exe (in windows explorer or my computer, of course),

      (ii) click on Properties,

      (iii) navigate to the Security tab and click on the Advanced button toward the bottom of the window,

      (iv) navigate to the Owner tab and click Edit

      (v) select your username (or you could choose Adminstrator and click Okay,

      (vi) select your name from the drop-down and click Okay twice,

      (vii) (at this point you should see no more windows related to Properties), right click on notepad.exe again, (vii) navigate to the Security tab again, select your name from the Group or user names box (top half of the window),

      (viii) check the box next to Allow in the Permissions for Administrators section (bottom half of the window); once you do this, the check-boxes next to Modify and Write should get checked also

      (ix) click Okay, then click Yes if Windows warns you about changing permissions (bc we do what we want!)

    • Follow (i) through (ix) for each of the other two instances of notepad.exe in the other relevant folders (one other instance if you have 32-bit Windows 7).

    • Now that we've given ourselves permission(s) to have our way with it, let's delete each instance of notepad.exe (i.e., from each of the relevant folders).

  3. "You're a fine symbolic link, won't you back that app up?"

    • For some reason, Windows 7 doesn't provide a built-in graphical utility for making symbolic links (and I try to avoid downloading 3rd party apps when I can) so let's fire up cmd.exe. We'll need to start it up as Adminstrator: click on the Start button, type cmd into the search box, right-click on cmd.exe and click on Run as administrator.
    • The command for creating a symbolic link is called mklink (you can type all caps if you want but I try to avoid screaming at my computer when possible) and it takes the following format mklink /h "<Path:\To\New\Link.exe>" "<Path:\To\Source\File>". (The /H option ensures we create the right type of link.) Note: if you prefer using Powershell, you'll have to preface the commands with cmd.exe /c (e.g., cmd.exe /c mklink /h ...)
    • Here's what the command looked like for me: mklink /h "C:\Windows\notepad.exe" "C:\Program Files (x86)\Notepad++\notepad++.exe". Notice that we don't need to use < or > when typing the command.
    • Now, run the command again for other two relevant locations (or one if you're on 32-bit).

That's it! If you click on Start, type in notepad into the search box and press Enter (no need to wait for anything to pop in the serach), it should open up your new Notepad app.

I know this is detailed but I wanted to write this at a level of detail which I wish I'd had when going through this process for the first time...so sorry if it came off as 'micro-manage-y'!

Now we get to the most important step: time to celebrate our victory over he-who-must-not-be-notepad by going to YouTube and watching Juvenile's hit from the 90s which inspired this post (parental advisory, of course).

  • appreciate the verbosity. I was attempting to do the exact same thing ;) Worked a charm! – Stafford Williams Dec 3 '14 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.