30

After installing Adobe PDF reader, it opens files with the .PDF file extension. Ones' default web browser opens .html files and notepad opens .txt files, etc.

Where exactly in the registry are these filetype - program associations stored in the registry?

In other words, how does Windows know with which software/program it must open a certain file(type)?

claws
  • 4,649

8 Answers8

20

The open with associations are all stored in HKEY_CLASSES_ROOT.

This is a special registry hive that combines the local user's associations in HKEY_CURRENT_USER\Software\Classes with the system's associations in HKEY_LOCAL_MACHINE\Software\Classes.

Here's a shot from my registry for the PDF association you mention in your question:

PDF file association in the registry

Gareth
  • 19,080
12

Just to extend Gareth's answer:

From playing with the registry it looks like

  • entries from HKEY_CURRENT_USER\Software\Classes override entries from HKEY_LOCAL_MACHINE\Software\Classes in the HKEY_CLASSES_ROOT\Software\Classes
  • setting file's extention association from command line using assoc command acts upon HKEY_LOCAL_MACHINE\Software\Classes
  • setting file type association from command line using ftype command acts upon HKEY_LOCAL_MACHINE\Software\Classes
11

With current Windows versions,

#1 First you need look up HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\[EXT]\UserChoice\ProgId if it exists. If not, goto #5.

#2 The ProgId is a file-class, e.g. Python.File (=> goto #6) or similarly an application-id, e.g. Applications\SciTE.exe (=> goto #3)

#3 Locate the application id Applications\SciTE.exe like HKEY_CLASSES_ROOT\Applications\SciTE.exe\shell\open\command. The default value is the command to run.

#4 Done.

#5 Lookup Computer\HKEY_CLASSES_ROOT\[EXT] 's default value for a file-class, e.g. Python.File

#6 Lookup the file-class Python.File like HKEY_CLASSES_ROOT\Python.File\shell. The default value is a default command, e.g. edit (defaults to open if not existing).

#7 Look up its edit command like HKEY_CLASSES_ROOT\Python.File\shell\edit\command. The default value is the command to run. Note: The other available commands for a file-class are shown in Explorer, when right-clicking on a file.

Note: HKEY_CLASSES_ROOT joins the Software\Classes of HKEY_CURRENT_USER (higher priority) and HKEY_LOCAL_MACHINE

kxr
  • 251
3

While the answers are (probably, I didn't check) correct, the sane way to modify file associations is with the GUI Microsoft designed for it. (That is, if you are a user and not a setup developer.)

Here is one tutorial with nice pictures, I found it with google: http://www.digitalcitizen.life/how-associate-file-type-or-protocol-program

But you can just open start (win7 menu or win8 screen, doesn't matter) and type file association, enter and it should open the correct control panel link. (Control Panel\Programs\Default Programs\Set Associations).

Gareth
  • 19,080
2

The problem with many of these methods is that Windows doesn't really handle the possibility of different executables having the same name. When using the GUI, there is no way to know to which one they are referring.

That is because, in Win 7 anyway (I haven't checked win 10), the default program for explorer is stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ But if you look there you will find for example in the OpenWithList key, something like LibreOfficeWriterPortable.exe in my case. But I have multiple versions of that program, all with the same name, so changing that key is not going to help.

To find what it actually points to, you have to go to (in my case)

HKEY_USERS\S-1-5-21-966747605-1980359026-2421819745-1000\Software\Classes\Applications\LibreOfficeWriterPortable.exe\shell\open\command

to find out what that will actually open, i.e. what the named they are using actually points to.

pbpb
  • 129
0

In windows 10, you can identify that a program support what file extensions by 2 methods.

1. "Set defaults by app"

Go to Settings -> Defaults Apps -> Set defaults by app. On the next page, Click management on the app that you want. In this situation, you can identify file associations that supported the app.

2. Find in Registry

Go to Registry Editor. And find the entry of Computer\HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications. This registry entry shows that where each program is logging its file associations. You can find the value of entry by the app name that you want.

In my case, I find an "IrfanView.exe" and its value is computer\HKEY_LOCAL_MACHINE\SOFTWARE\IrfanView\Capabilities\FileAssociations. if go to its location, you can find the result like below.

enter image description here

Toto
  • 19,304
0

Windows XP also uses the "application" data value in FileExts\[EXT]. It is apparently similar in effect to the progid value in the "UserChoice" key in Win7+. I have, at present, been unable to find any further information.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ext "application"=notepad.exe

user165568
  • 926
  • 5
  • 16
-1

In my case, I was trying to open a random extension with word pad, so what I did was:

  1. Start -> Run -> cmd.exe
  2. assoc .bhf=txtfile
  3. Then find a file with that extension in windows explorer
  4. Right-click -> Open With -> Choose Another App -> Select Checkbox "Always use this app to open .BHF files"
  5. Select program of choice (if not visible select "More apps"/"Look for another app on this PC")

In my case, I didn't have the UI options for selecting the default program or the checkbox, until I ran the command in step #2. I think once Windows thinks of a file like a "text" file, I guess it's no longer considered "too dangerous" to allow you to associate it as you see fit...