9

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?

9

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.
8
  • 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! – user1580348 Feb 25 '15 at 15:05
  • 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 – user1580348 Feb 25 '15 at 15:09
  • @user1580348: Yes, this is ONLY necessary to store the localized strings e.g. Arabic or Chinese. – Leo Chapiro Feb 25 '15 at 15:40
  • Hi duDE, is it possible to add custom sections with name-value pairs to the desktop.ini file, or would this conflict with the normal operation? The reason is: In addition to the folder-icon functionality, I want to store other custom information in this file. – user1580348 Feb 25 '15 at 19:12
  • Try it out, I would say it's possible ... – Leo Chapiro Feb 25 '15 at 19:54
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.