I see you're writing to HKEY_CLASSES_ROOT
with that reg file in the question. This hive is a merged view of HKEY_LOCAL_MACHINE\Software\Classes
and HKEY_CURRENT_USER\Software\Classes
.
The reason your file only works for previously unassociated files is that writes to HKEY_CLASSES_ROOT
redirect to the appropriate key in HKEY_LOCAL_MACHINE
(the hive for system defaults and all-user settings). However, you will run into a problem because file association settings in HKEY_CURRENT_USER
(which contains per-user settings) override system defaults.
Furthermore, if the extension is controlled by a "default programs" association, it's file association information is stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<.ext>
. You can check if your extension has this association by checking for the existence of that key.
You can edit your .reg to work for any file, including previously associated files, by duplicating it for those keys in both HKEY_LOCAL_MACHINE
and HKEY_CURRENT_USER
. Similarly, you can remove the association by deleting the appropriate keys in both hives (including the FileExts
location).
A working .reg file to delete an association for a particular extension looks like this (which deletes .blerg
assocations):
Windows Registry Editor Version 5.00
; Created with Default Programs Editor
; http://defaultprogramseditor.com/
; Delete Extension
[-HKEY_LOCAL_MACHINE\Software\Classes\.blerg]
[-HKEY_CURRENT_USER\Software\Classes\.blerg]
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.blerg]
However, if you'd prefer not to have to educate yourself on registry internals and the various arcane aspects of Windows file association, I'd recommend that you'd use Default Programs Editor to make these changes- you can even export an action to a .reg file, which seems to fit your needs perfectly.
![Default Programs Editor delete extension and save as .reg file](../../I/static/images/d1e30f302d30b54e65aeaf7fa41b73604f5c99a7f7461ce852498ba40908799a.png)
In your case, it's as simple as clicking File Type Settings
, then Delete an extension
. Select the extension, and instead of saving to the registry, press the small arrow on the Delete Extension
button, and click Save to .reg file...
. This will produce a complete and commented .reg file of this action which you can save or distribute to other machines.
1+1 for Default Programs Editor. Mentioned in several answers, but found it here first. Much simpler, and even though it's a utility to install, it's very focused on its job. – goodeye – 2011-12-11T03:34:02.093
1What a terrific, well-explained answer. Thank you Factor Mystic -- this works like a charm! – Philipp Lenssen – 2009-10-07T11:18:06.203