27

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)?

1

7 Answers 7

18

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

1
  • The start of the solution section on this page (support.citrix.com/article/CTX115676) succinctly backs this up and shows how the assoc and ftype CMDs can be useful when looking at what specific file extension associations are, without needing regedit.
    – Dallas
    Dec 1, 2021 at 3:44
10

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
7

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

1
  • This is kickass answer, thanks alot!
    – wormer
    Oct 16, 2022 at 18:06
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).

2
  • 2
    Maybe that worked once upon a time. Now all Win10 gives me is "Look for an app in the Microsoft Store". BS.
    – Ralf
    Nov 21, 2019 at 18:02
  • Works for me now on Windows 11
    – Rory
    May 24, 2022 at 11:24
1

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.

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

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

2
  • You're not seeking to understand the intent of the question. He asked: "In other words, how does Windows know with which software/program it must open a certain file(type)?" He's obviously looking at understanding how Windows associates file types. This answer addresses a common Windows problem that people run into trying to control program associations when Windows stops them from doing so. The exact registry path was already provided in a different answer. If the answer above doesn't work for somebody in the same situation, this answer will be much easier. Apr 1, 2021 at 23:20
  • Where is it only referencing Windows 7? I see "Windows 7", "Windows XP" and "Windows" generally tagged? Apr 2, 2021 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .