How to manually set file associations (super detailed)

Table of contents

1. What is file association?

2. How to set up file associations

3. Summary


1. What is file association?

Whenever you open a txt file, are you a little confused: Why does the system know that the txt file was opened with Notepad? Is this how the system is set up? But why do txt files open with Notepad++ by default after you install software like Notepad++? ? ?

In fact, it's all because of Windows file associations.

File association is to set which program should be used to open each file. For example, .txt is opened with notepad, .docx is opened with word, .ppt is opened with PPT...

Many software will set file associations when they are installed.

File association settings are stored in the registry, so setting file associations is usually achieved by writing to the registry. But there are thousands of entries in the registry, which one is the file association? ? ? I checked online and found that most blogs talked about a bunch of methods, each of which was briefly mentioned. However, only a few of them were useful, and most of them were useless. After reading this, I was confused. I only knew the general idea, and didn’t explain how to operate it in detail. . Some blogs directly tell you the code without knowing what the code is doing.

In the end, I could only look for items related to file associations in the registry and observe the format of these items. After hours of research, I finally figured it out. . .

2. How to set up file associations

Let’s get to the point. How to set up file associations?

Next, our task is to set the .aaa file association and let the .aaa file be opened with Notepad. The same applies to other files, so I only give this example.

1. Press and hold [Win+R], enter regedit, and press Enter to open the Registry Editor.

2. Find HKEY_CLASSES_ROOT and create a new subkey under it. You can name it whatever you want, but remember the name. For example, the name of my new item is love.

3. Modify the default value of the newly created item. This default value will be used as the description of the file (for example: the description of txt is "Text Document"). The file description I set here is 12345.

4. Create three nested sub-items under the new item: "shell->open->command".

 

5. Modify the default value of the command sub-item, which is the program (associated program) executed when the file is opened. For example, what I write here is "C:\Windows\System32\notepad.exe %1", which means to open the file with Notepad. Where %1 refers to the file to be opened.

6. Create a new subkey under HKEY_CLASSES_ROOT, whose name is the extension of the file you want to associate. We want to associate the .aaa file, so the new subkey name is .aaa (note that it is .aaa not aaa, there is a dot in front of aaa)

7. Finally, modify the default value of .aaa (note! It is the default value of .aaa instead of love), and change it to the subkey name created in step 2. The sub-item we created in the second step is called "love", so the default value is changed to love.

 8. Create a new .aaa file arbitrarily, open it, and find that it is opened with Notepad by default.

3. Summary

File associations are very useful. Not only will file associations be set when software is installed, but even hackers often use file associations to attack. Many viruses also infect by modifying file associations. You can even use it to prank...

Guess you like

Origin blog.csdn.net/nnKevi/article/details/125638456