DelphiFAQ Home Search:

Change file type association for a certain extension


comments3 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.


I need to edit HTML files on my hard disk for a while now and want to open each of them with Notepad instead of FrontPage. So what I want to change is how Windows opens HTML documents when I double click on them. I don't want to have to right click on each of those documents, select 'Open With...' and then choose notepad. Is there a quick way to change the association?


You could rename all your files from *.html to *.txt - difficult if you have tons of subdirectories. Or maybe something else keeps you from it (e.g. you may want to test the HTML files and they are linked across each other).

The solution is a Windows command line tool called assoc.

The box below shows what you can do in your case.

# at the command line prompt, enter these commands

C:\Temp>assoc .html

C:\Temp>assoc .txt

# now change the association
C:\Temp>assoc .html=txtfile

# now do your work

# undo the change
C:\Temp>assoc .html=htmlfile

# save all your associations to a config file:
C:\Temp>assoc >assoc_config.txt


2008-09-10, 12:19:48
anonymous from United States  
There's no reason to bring the command-line into this. Besides, what if you want to open HTML files with Wordpad, or VIM, or Internet Explorer, or whatever? This solution doesn't address that.

The GUI way is:

1. Go to the file explorer (right-click the 'Start' button and select 'Explore' from the context menu).
2. Select Tools -> Folder Options.
3. Select the 'File Types' tab. This will bring up all known file-types in alphabetical order.
4. Scroll down to .HTM and .HTML.
5. Click on them (you'll modify .htm and .html separately, so one at a time), and hit the 'Change...' button.
6. Select Notepad as the default application for opening .html/.htm files.

The menu structure may be slightly different between versions of Windows, but 'Folder Options' has always been the

You'll probably be able to select notepad from a list. If not, you'll have to find it in the file structure. On Windows Server 2003, the Notepad is located at C:\Windows\system32\notepad.exe.
2008-12-20, 12:45:42
[hidden] from United States  
Obviously, you have not used Vista: Vista has no Folder Options.
2009-03-25, 15:26:00
anonymous from United States  
Great post, very helpful for files that don't allow you to Open With.



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: