13

After upgrading to Win 11 a bit over a week ago, I found that my Image File Execution (i.e. HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe) replacement for Notepad was no longer working; all my text files opened in Notepad instead of Notepad2 as it used to in Win 10.

I checked my registry and found that IFE for notepad.exe was still in place. However, text files still opened in notepad. I therefore proceeded to check HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\notepad.exe and replaced the relevant values with Notepad2, my preferred text application. After that, typing notepad.exe in any terminal window opens Notepad2 but double-clicking text files still opens them in notepad.

My question therefore is, is there any straightforward way to make notepad2.exe (or any other text editor) replace notepad.exe as was possible in earlier versions of Windows?

Toto
  • 19,304

5 Answers5

10

I found that uninstalling the Windows Store Notepad app reverted the Win10 and older behaviour.

2

TLDR

If removing the Microsoft Store Notepad did not help, you can run reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f as admin to clean up the redirection record completely and then re-install notepad2 that will re-create the record in the desired form.

Details

This problem annoyed me enough, so I decided to dig a bit deeper, user Chino Chang does have a point in their answer.

There is pretty good description of how Image File Execution Options works in the linked article. The salient point is that there is now a UseFilter value under the Image File Execution Options/filename key, and if it is set, then not every notepad.exe will be redirected to yours, but just those that are specified in the subkeys. Since the Microsoft Store one does not seem to be specified it does not get redirected.

Version 6.1 extends the scheme to differentiate according to the whole name that is supplied for the executable. The extension is a little complicated because, of course, the whole pathname can’t itself be a subkey. If the subkey just for the filename contains a particular value (to show that the extension applies) and a suitable subkey (containing a particular value whose string data matches the executable’s whole name), then the function returns the deeper subkey instead. Extension to a subkey for the whole name of the executable applies only if the subkey for the filename contains a REG_DWORD value named UseFilter whose dword of data is non-zero If the UseFilter value is absent from the subkey for an executable’s filename, or if it is present but has the wrong type or size or is zero, then all executables with this filename have the same Image File Execution Options and the subkey for the filename is what the function sticks with. Given that the subkey for just the filename has a correctly configured UseFilter, it may have any number of subkeys that are each for a different pathname. The names of the subkeys are immaterial. What matters is whether a subkey has a REG_SZ value named FilterFullPath whose data matches the executable’s whole name

This was my case, I did have UseFilter and I did have the subkeys with some paths. Getting rid of these resolved the issue.

Note: Notepad store app can be deleted with the following command if required:

Get-AppxPackage | Select-Object -ExpandProperty PackageFullName | Select-String notepad | Remove-AppxPackage
1

Not sure whether this is the solution you want, but as a workaround go to "Default Apps" settings in Win11 and change the default action for the extension .txt to "open with Notepad2". Other extensions also can be changed as required.

kordell
  • 19
1

In additional, set FilterFullPath to your editor.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]
"Debugger"="C:\\ProgramData\\scoop\\apps\\notepad3\\current\\Notepad3.exe /z"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\0] "FilterFullPath"="C:\ProgramData\scoop\apps\notepad3\current\Notepad3.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\1] "FilterFullPath"="C:\ProgramData\scoop\apps\notepad3\current\Notepad3.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\2] "FilterFullPath"="C:\ProgramData\scoop\apps\notepad3\current\Notepad3.exe"

0

What @Alex Essilfie said above worked for me. So, using the bits and pieces of the replies above, the following recipe worked for me. (I also deleted the bindings as discussed by @Andrew Savinykh above.)

So, in cmd.exe, I did:

:: first uninstall notepad2, if already installed
winget uninstall flos-freeware.Notepad2 
:: then delete the "bindings"/"redirection records", just to be sure
reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f

:: uninstall "new" notepad (I use cmd.exe, invoke powershell to do this): POWERSHELL -COMMAND "Get-AppxPackage | Select-Object -ExpandProperty PackageFullName | Select-String notepad"

:: and reinstall notepad2 using winget install flos-freeware.Notepad2

(this snippet as gist here)

  • No reboot required, this worked instantly for me.
  • Windows 11 24H2 build v 10.0.26100.3775.

Of course, if you want to backup the redirection record bit, before deleting, this will do that for you:

reg export "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" notepad-bindings-bak.reg
mawi
  • 131