Self-created desktop.ini does not work

9

2

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?

user1580348

Posted 2015-02-25T14:15:18.993

Reputation: 742

Answers

7

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.

duDE

Posted 2015-02-25T14:15:18.993

Reputation: 14 097

1Thanks! 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 – 2015-02-25T15:05:26.460

However the desktop.ini created by Windows with the Properties dialog is encoded in ANSI, not in Unicode. See this screenshot from notepad++ http://i.imgur.com/xLtzQ7G.png

– user1580348 – 2015-02-25T15:09:47.137

@user1580348: Yes, this is ONLY necessary to store the localized strings e.g. Arabic or Chinese. – duDE – 2015-02-25T15:40:57.977

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 – 2015-02-25T19:12:19.357

Try it out, I would say it's possible ... – duDE – 2015-02-25T19:54:34.213

Of course I've already tried it out and it seems to not conflict with normal operation. However, this could be different in the long-term. That's why I asked - it could be that somebody knows it better. That's why people ask questions here. No need to vote something down because someone asks a question... – user1580348 – 2015-02-25T21:25:53.180

The corrent encoding of desktop.ini should be UTF-8, to be exact! – Daniel – 2018-08-09T20:45:14.283

1

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.

Nnnes

Posted 2015-02-25T14:15:18.993

Reputation: 156