Home » Questions » Computers [ Ask a new question ]

Delete Windows file association using .reg file

Delete Windows file association using .reg file

Question: Using a .reg file, how do I completely remove a file type association? I tried e.g. deleting HKEY_CLASSES_ROOT\myextension_auto_file but that's apparently not enough.

Asked by: Guest | Views: 33
Total answers/comments: 1
Guest [Entry]

"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.

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."