How to associate files with Notepad in Win11

In this article, I will show you how to associate files with Notepad in Windows 11.

Introduced before How to revert Notepad to an older version in Windows 11 After restoring Notepad to the previous version, for exampleextensionHowever, we have received inquiries from users asking if it is possible to associate files such as ".js", ".html", and ".py" with Notepad.

If you revert to an older version of Notepad, you may not be able to associate it with Notepad using the usual methods.

Also, some apps cannot be modified in the normal way.

プログラムから開く
プログラムから開く

Even if you specify "C:\Windows\System32\notepad.exe" from "Open with", it will not be associated.

The selected program cannot be associated with this file type. Please choose another program.
The selected program cannot be associated with this file type. Please choose another program.

Please refer to this if you are unable to change the association using the normal method.

table of contents

How to set file associations to Notepad

To associate files with the old Notepad, you will need to edit the registry.

If you operate the registry incorrectly, it may cause problems such as the system being unable to start. Please make a backup in advance using system restore or similar, and proceed at your own risk.

To avoid panicking if your PC suddenly breaks down, it's a good idea to have a standard backup software to protect your important photos and data.

1. Press Windows key + R to open Run, type "regedit" and press Enter.

2. The Registry Editor will open. For example, if you want to change the file association for ".js", open the following key:

HKEY_CLASSES_ROOT\.js

The HKEY_CLASSES_ROOT\ key contains information about many file extensions.

".js", ".html", etc. after HKEY_CLASSES_ROOT\extension.

レジストリエディター
レジストリエディター

3. With the ".js" key selected, double-click the "(Default)" value data in the right column to open it.

Editing strings
Editing strings

4. Copy this value data and close "Edit String".

5. Press the "Ctrl + F" keys on your keyboard.

6. "Search" will open, so paste the value you copied into "Search value".

7.Uncheck "Value" and "Data" under "Search for".

8. Click Find Next.

Search
Search

This will search for the following key:

HKEY_CLASSES_ROOT\JSFile
レジストリエディター
レジストリエディター

FirstBack up your keysThen proceed to the next step.

9. Double-click each key: JSFile > Shell > Open > Command, and look at the value data for "(Default)" in the right column.

レジストリエディター
レジストリエディター
C:\Windows\System32\WScript.exe "%1" %*

The application registered here is the program that will run when you double-click a ".js" file.

10. Double-click "(Default)" to open it and change the value data as follows: (All half-width characters)

C:\Windows\System32\notepad.exe "%1" %*
Editing strings
Editing strings

11. Click OK to exit Edit String.

At this point, double-clicking a ".js" file will open Notepad.

Try changing ".html" and ".py" in the same way.

If the extension key does not exist

If the extension key does not exist, try adding it.

For example, suppose there is no ".py".

1. Right-click on "HKEY_CLASSES_ROOT" > New > "Key".

レジストリエディター
レジストリエディター

2. Rename "New Key #1" to ".py".

レジストリエディター
レジストリエディター

3. With the ".py" key selected, double-click "(Default)" in the right column to open it.

4. Enter "pyfile" in the Value data and click OK.

Editing strings
Editing strings
レジストリエディター
レジストリエディター

Now that you have added the ".py" key, return to the "HKEY_CLASSES_ROOT" key.

5. Right-click on the "HKEY_CLASSES_ROOT" key > New > "Key".

6. Change the name of "New Key #1" to "pyfile" as mentioned earlier.

7. Right-click on the "pyfile" key > New > "Key".

8. Rename "New Key #1" to "Shell".

9. Right-click on the "Shell" key > New > "Key".

10. Rename "New Key #1" to "Open".

11. Right-click on the "Open" key > New > "Key".

12. Rename "New Key #1" to "Command".

13. With the "Command" key selected, double-click "(Default)" in the right column to open it, and enter the following command in the value data:

C:\Windows\System32\notepad.exe "%1" %*

14. Click OK.

レジストリエディター
レジストリエディター

At this point, you can double-click the ".py" file to open it in Notepad.

Change a file's icon

Files with unregistered extensions have a white icon by default.

The icon is white
The icon is white

Let's change this icon to a text file icon.

1. Right-click on the "pyfile" key you just added and click New > Key.

2. Rename "New Key #1" to "DefaultIcon".

3. With the "DefaultIcon" key selected, double-click "(Default)" in the right column to open it, and enter the following command in the value data:

 C:\Windows\System32\shell32.dll,70
Editing strings
Editing strings
レジストリエディター
レジストリエディター

4. Once you're done editing, close Registry Editor and sign out of your PC.

Once you sign in, the icon will change to a text file icon.

Changed to text file icon
Changed to text file icon

If the icon is not updated when you change it again, try deleting the icon cache.

I want to read it together
[Solved] Desktop icons are not displayed properly? How to fix black borders and non-display issues When using Windows, have you ever experienced display issues like black edges around desktop icons, or icons you thought you had changed going back to their original state?

If you cannot change it, such as ".html"

If you are unable to change the association using the above method, or if specifying "C:\Windows\System32\notepad.exe" from "Open with" does not result in an association, try the following method.

1. For example, if your file is ".html", first open the following key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\OpenWithProgids

*If the file has a different extension, the ".html" in this key will be the extension, so open the desired key.

2. With the "OpenWithProgids" key selected, you can see the value "htmlfile" (REG_NONE) in the column on the right.

レジストリエディター
レジストリエディター

3. Right-click on the value "htmlfile" and click "Rename".

レジストリエディター
レジストリエディター

4. Rename the value to "txtfilelegacy".

レジストリエディター
レジストリエディター

5. Now that the registry editing is complete, try right-clicking on a ".html" file.

If you move the mouse cursor over "Open with," you'll see that "Notepad" has been added.

6. Just click "Select another program".

Right-click menu for .html files
Right-click menu for .html files

7. "Notepad" is displayed under "Recommended apps" under "Choose an app to open .html files." Click "Notepad" and then click "Always use."

Select an app to open an .html file
Select an app to open an .html file

8. The ".html" file will then open in Notepad.

At this point, ".html" files will be associated with Notepad.

If you click "Refresh" from the "View" menu in the Registry Editor, the value "htmlfile" will be restored.

レジストリエディター

The icon has also changed from a browser icon to a text file icon.

Changed to text file icon
Changed to text file icon

If you want to revert, select your browser from "Choose another program" and click "Always use."

Added the ability to open selected links or open them in a browser to Win11 Notepad.

If you found this article helpful, please share it on social media.

Person who wrote this article

Driven by questions arising from my daily PC use and the desire to "do more," I have been pursuing self-study in Windows since around 2008. I am sharing the "aha!" techniques and solutions I discovered through trial and error with the sole purpose of helping you in your PC life.

View profile

Comment:

To comment

[About submissions]
We welcome any questions or information regarding the content of the article.
However, please note that content unrelated to the purpose of the article, criticism of specific individuals or organizations, offensive language,Inappropriate wordsComments containing the above may be deleted or made private without notice at the discretion of the administrator.
Please note that spam may be automatically deleted by anti-spam measures.

CAPTCHA


table of contents