17

Currently I have associated various text file formats (.md, .txt, .taskpaper) to be opened by sublime text. This results in ALL of them being assigned the SAME icon file, namely the sublime text icon.

How can I get each file format to have its own unique icon file (supplied by me)?

First Attempt

Change the icon associated with one of the file types using FileManType by Nirsoft. The Result: it changes the icon for ALL of the file types that sublime opens (not what I wanted)

Second Attempt

Now I tried to get clever...

  • (1) created a shortcut of the sublime exe for each file format
  • (2) gave each shortcut its own unique icon, which the shortcut accepted
  • (3) set the program that (say) .md files opened with to its own special shortcut etc...

This time it just ignored the icons contained in the shortcuts and remained with the sublime icon

Any ideas?

JosefZ
  • 13,855
Sam
  • 282

7 Answers7

8

Use Default Programs Editor.

Among other things, this editor allows you to replace the icon for a single file type while still retaining the associated program.

I realize this is basically a link only answer, however, I'm not aware of any other way to do this without direct registry editing. If you're interested in the specific edits that need to be made, consider using procmon from Sysinternals to capture the registry activity during an icon change.

You may be able to download version 2.7.2675.2253 of the Default Programs Editor (from Friday, February 15, 2013) at Chocolatey Gallery.

7

You can refer to this MSDN article

  1. Create a Sub Key named DefaultIcon in HKEY_CLASSES_ROOT\.extension

  2. Assign the DefaultIcon Sub Key a default value of type REG_SZ that specifies the fully qualified path for the file that contains the icon.

  3. Logoff and log back in

EDIT: it looks like the Windows 10 registry has separate entries for each app, so for instance I wanted to change my Notepad++ .ico, so I found the HKEY_CLASSES_ROOT\Notepad++_file entry and modified the existing DefaultIcon path. Forgot to add this. Its one of the comments  

clhy
  • 6,514
6

This is pretty difficult, and for very interesting reasons.

Since Windows Vista, file types are mostly managed by the "User Choice" option (as can be seen from the FileTypesMan interface), which bundles the program, icon, menu options etc. into one file type such as "ChromeHTML". Back then we can simply create a new file type, and the modify the User Choice option of a given file extension to the new type, but now things are different. Since Windows 8, the system introduces a "hash" to the User Choice option, which is basically a password that protects the file extension from being modified by anyone other than the system UI. Pretty much all file type managing tools, including FileTypesMan and Default Programs Editor, couldn't break that password, and therefore can't help you change the User Choice.

There's only one exception that I'm aware of. It's called SetUserFTA. The author of the tool somehow reverse-engineered the system and figured out the exactly algorithm used to create the hash, and therefore can indeed change User Choice for a single file extension without altering anything else. The tool can be downloaded from

https://kolbi.cz/blog/2017/10/25/setuserfta-userchoice-hash-defeated-set-file-type-associations-per-user/

So now all you need to do is to create a new file type as in the old days, and use SetUserFTA to change the extension.

3

If multiple file extensions are mapped to the same ProgId, the same icon will be used. If you need different icons for different file types/extensions, assign different ProgId names, setting the same application for the "open" verb.

For example:

Make .md point to sublime_md

Make .txt point to sublime_txt

and so forth... It becomes tedious only if you create hundreds of those custom files types.

And the program that's assigned for these ProgIds (sublime_txt, sublime_md and sublime) are exactly the same, differing only in the "DefaultIcon" value.

HKCR\sublime_txt\DefaultIcon Set default vlaue to "path:\texticon.dll"

HKCR\sublime_md\DefaultIcon Set default vlaue to "path:\mdicon.dll"

To better explain using a sample REG file:

Windows Registry Editor Version 5.00

;For .md extension
;-----------------
[HKEY_CLASSES_ROOT\.md]
@="sublime_md"

[HKEY_CLASSES_ROOT\sublime_md\DefaultIcon]
@="c:\\mdicon.dll"

[HKEY_CLASSES_ROOT\sublime_md\shell\open]
@="Open"

[HKEY_CLASSES_ROOT\sublime_md\shell\open\command]
@="c:\\sublime.exe %1"


;For taskpaper extension
;-----------------------
[HKEY_CLASSES_ROOT\.taskpaper]
@="sublime_task"

[HKEY_CLASSES_ROOT\sublime_task\DefaultIcon]
@="c:\\taskicon.dll"

[HKEY_CLASSES_ROOT\sublime_task\shell\open]
@="Open"

[HKEY_CLASSES_ROOT\sublime_task\shell\open\command]
@="c:\\sublime.exe %1"
w32sh
  • 12,379
1

Nirsoft's FileTypesMan tool

On Windows 11, I used the freeware utility called Nirsoft's FileTypesMan tool ;

Registry Changes investigation:

After using it it appears that it modifies the file extensions associated Default Programs DefaultIcon to the ico file that you define.

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\...<default program>...\DefaultIcon]

1

I recommend Types, which has a simple interface meant for this exact use. Just install, start, find the file extension and change its icon.

0

I just went through this and thought I'd share my specific solution. I like to use Chrome to view PDF files but hated that all PDF files looked like Chrome web pages, or Edge web pages! I made two changes to the registry although I don't believe the .pdf registry change was necessary.

Right click, run Regedit as an administrator and add the two keys as below:

HKEY_CLASSES_ROOT>.pdf>
      (Default) = pdf_auto_file   [Locate this program name for step 2]
      DefaultIcon       [added this key to the .pdf]
         (Default) = C:\Windows\system32\shell32.dll,75 [set the value of DefaultIcon]


HKEY_CLASSES_ROOT>
   pdf_auto_file>
      DefaultIcon       [add the DefaultIcon key to pdf_auto_file]
         (Default) = C:\Windows\system32\shell32.dll,75  [set the value of DefaultIcon]

I used a shareware program called IconExplorer to locate the icon I liked and get the correct path.

Gareth
  • 19,080
Jeff Sadar
  • 11
  • 1