Windows File Association – How to Change Default Program When Program Has Moved

file associationwindowswindows 7

In Windows 7, if I have already associated a program, say Notepad2.exe, with a filetype, say .txt then moving the path to Notepad2.exe (e.g., moving the folder) breaks the association. The problem I have is that I do not see a way to fix the association.

The normal methods of choosing the filetype association, through right-click > properties or through the control panel, do not work. When you reach the "Choose the Program you want to use to open this file" window you can try browsing for the .exe you want, but after pointing it to the new path, the program Notepad2.exe will not in fact be there when you return to the "Choose the Program you want to use to open this file:" window.

If you rename Notepad2.exe to something else, like Notepad2a.exe then you can associate it as normal. So apparently the problem was that Windows assumes the name of the .exe identifies the program. Since it obviously remembers the old path to Notepad2.exe one could interpret this behavior as silently complaining that it doesn't want to remember two Notepad2.exes with different paths.

Using the registry I have tried deleting the remaining associations to Notepad2.exe (e.g., using this answer https://superuser.com/a/49617/223560). I have also adjusted the registry entry for the MRU list to remove mention of it. But this was not enough to make windows 'forget' about it. Since this is a portable application, there is no uninstaller to help make windows forget about it.

Is there a way to fix this mess? Changing the name of Notepad2.exe or creating a 2nd copy/shortcut with a different name is not an acceptable solution to me. I want to make it work like it normally should.

Edit:
Poking around the registry gives some clues. The registry keys under OpenWithList contains keys with values like Notepad2.exe — just the name and not the path. In the registry under UserChoice there is a key Progid with value Applications\Notepad2.exe. That doesn't look like a path, and I'm not sure how windows decides what path that corresponds to.

Best Answer

I seemed to have found it:

HKEY_CLASSES_ROOT\Applications\Notepad2.exe\shell\open\command

Edit this key to the new path.

Related Question