15

In Windows 7 x64 SP1, when creating a desktop.ini file with a text editor (e.g. notepad, notepad++) and saving it inside a folder, it does not work. For example, I have saved this desktop.ini inside a folder:

[.ShellClassInfo]
IconResource=C:\Windows\explorer.exe,0
[ViewState]
Mode=
Vid=
FolderType=Generic

But it does not work, i.e. the folder icon does not change! I have tried ANSI or Unicode encoding, neither does work.

Of course, when I change the folder icon with the Properties dialog, it does work: The folder shows the new icon and the desktop.ini file is created inside the folder with exactly the above format.

How can I make this work?

2 Answers 2

15

The desktop.ini should have the attribute of system, and the folder containing it also needs to have the attribute of system for it to have an effect.

Use the following procedure to customize a folder's style with Desktop.ini:

  • Use PathMakeSystemFolder to make the folder a system folder. This sets the read-only bit on the folder to indicate that the special behavior reserved for Desktop.ini should be enabled. You can also make a folder a system folder from the command line by using attrib +s FolderName.
  • Create a Desktop.ini file for the folder. You should mark it as hidden and system to ensure that it is hidden from normal users.
  • Make sure the Desktop.ini file that you create is in the Unicode format. This is necessary to store the localized strings that can be displayed to users.
10
  • 3
    Thanks! I only changed the attributes of the desktop.ini to system and hidden. I didn't know that also the folder needs the system attribute. Now it works! Thanks again! Feb 25, 2015 at 15:05
  • 1
    However the desktop.ini created by Windows with the Properties dialog is encoded in ANSI, not in Unicode. See this screenshot from notepad++ i.imgur.com/xLtzQ7G.png Feb 25, 2015 at 15:09
  • @user1580348: Yes, this is ONLY necessary to store the localized strings e.g. Arabic or Chinese. Feb 25, 2015 at 15:40
  • 1
    Actually, only the system attribute for the containing folder is required. Everything else is unneeded in most cases.
    – Kar.ma
    Sep 15, 2020 at 7:46
  • 1
    Using Windows 11, I have found that the folder need the readonly attribute set, not system. attrib +r folder. This is what the GUI methods seems to do as well.
    – paradroid
    Mar 4 at 0:51
3

There is a very easy way to set the relevant attributes for the folder and its desktop.ini simply using Explorer.

  1. Create the desktop.ini file and save it in the top level of the folder. If you are using Notepad or something similar, make sure to save it as type "All Files" so that it does not save as desktop.ini.txt. The encoding is not important if you are not using any special characters.
  2. Click Properties in the folder's right-click menu and open the Customize tab.*
  3. Click OK (not Cancel or the X in the corner). There is no need to change any settings.

The folder's and desktop.ini's attributes have now been automatically set. The folder's displayed icon also refreshes immediately, without requiring deleting iconcache.db or restarting the computer. This also causes desktop.ini to disappear if Explorer is set to hide protected operating system files.

I have verified that this method works on Windows 7 and Windows 10.

*If you can't see the Customize tab, try right clicking the folder and then clicking Open Folder Location, then proceeding.

You must log in to answer this question.

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