5

I've got a simple desktop.ini file that applies a folder icon. It works just fine in a local folder.

I'd like it to work on a network location, as we have an external hard drive connected to our network. However, the desktop.ini file seems to have no effect on said network.

What am I doing wrong?

3

9 Answers 9

7

Why this happens

Windows will not read the desktop.ini unless it's a system file (seemingly readonly also works, but system file means it can stay hidden even when you set non-system hidden files to visible).

Why you seemingly can't fix it

On a Samba share (Unix implementation of SMB/network share protocol), sometimes even if you e.g., go to properties and set "read only", it will be ignored and not set. This is because Samba isn't by default storing these permissions - which seems to carry a (probably negligible) performance tax, as permissions are (AFAIK) set and read in alternate streams as textual data (probably wouldn't work if you're sharing some rudimentary FS such as FAT).

How to fix it

First make sure Samba stores DOS-style permissions (like "system"), by adding this line on your share definition:

store dos attributes = yes

Maybe you can add this to [Global], I've added it to a specific share instead.

Also, some people will tell you to edit the wrong file.

  • /usr/share/samba/smb.conf <= nonsense
  • /etc/samba/smb.conf <= right file

Restart Samba (sudo service samba restart), then make a quick check to see if you can use Windows Explorer to make a file read only for example, and if it persists.

Ok, now, you can make the desktop.ini a system/hidden file. To do this, go to the folder where it is with command prompt, and use:

attrib +s +h desktop.ini

Optionally also (if your icon is relative and stored in the same folder as mine is).

attrib +s +h folder.ico

Lastly, you need to mark the folder itself as read-only (makes no sense and sounds stupid, so you know it's legit).

attrib +r .

Of cours, you can (should) script this. Using MSysGit's bash, I did this on my whole NAS:

find . -type f -iname desktop.ini | while read -r i; do
    echo "Processing \"$(basename "${i%/*}")\""
    attrib +s +h "$i"
    attrib +s +h "${i%/*}/folder.ico" # Optional, in case you have these.
    attrib +r "${i%/*}"
done
3

You have to mark the folder as system or readonly, to make the desktop.ini work. readonly is better, as system folders are omitted from explorer-searches by default. attrib +r (folder name)

3

Have a read at this article http://helpdeskgeek.com/how-to/customize-folder-icons-desktop-ini/

IconFile

If you want to specify a custom icon for the folder, set this entry to the icon’s file name. The .ico file extension is preferred, but it is also possible to specify .bmp files, or .exe and .dll files that contain icons. If you use a relative path, the icon is available to people who view the folder over the network. You must also set the Icon Index entry.

In over words you will have to specify a relative path to your icon

eg ./hiddenfolder/mycoolicon.ico

Note that you may need to place two (or more) dots if the directory of the .ico folder lies outside of the location of the desktop.ini file- try experimenting and refreshing the Windows/File Explorer window.

Good Luck

3
  • 1
    No, that's not the problem. The desktop.ini file seems to be ignored, as none of the other commands in it are being processed either. Interestingly, I can't set it to be "hidden".
    – Eric
    Jun 7, 2010 at 10:28
  • What OS are you using to view the shared folder? Jun 7, 2010 at 12:47
  • Windows XP. [15 char limit]
    – Eric
    Jun 8, 2010 at 6:52
2

The problem has to do with the host containing the folder. Some network attached storage device (NAS), like the DROBO for example, run internally on Linux and their SAMBA network shell does not respect nor correctly implement the standard windows file attributes (R,S,H,A,I).

So relative paths will NOT help if the desktop.ini file is not read in the first place !!!

Because the host device, RAID, NAS or drive does not correctly report the "System" or "Read only" bit which windows expects to trigger the processing of the desktop.ini file, the file is never read and its contents do not matter.

Have found no solution to this problem yet.

2

If your IconResource is on a network location, try setting "EnableShellShortcutIconRemotePath"=dword:00000001 in

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer]

Or else it is local, try cd to the folder and running attrib +s . (I found that attrib +r . not working, but +s working)

1
  • At least in Windows 11 you neet to reboot before it will work. Drove me crazy till I found out. Dec 26, 2023 at 18:01
1

Create the following entry in registry [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer] "EnableShellShortcutIconRemotePath"=dword:00000001

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 30, 2022 at 18:50
0

To report correctly the file type "System" or "Read only", you have to modify the "smb.conf" in your NAS. In the [Global] section, add the line :

store dos attributes = yes

Enjoy !

M2C

2
  • Don't forget to restart Samba service with the cmd : sudo service samba restart
    – M2C
    Apr 22, 2016 at 17:36
  • I wasn't the one who downvoted you, but in my case I had to set this in a share definition. I had set in global and it was ignored. Jun 4, 2016 at 9:47
0

After many years of being annoyed at the fact that all the icons I had painstakingly added to my folder structure disappeared once I moved them to a network share...I finally decided to go down the rabbit hole and share my findings with all of you that suffer from the same problem:

Part 1: How do apply custom icons to local folders

  1. Create a new folder, or select and existing one you want to apply a custom icon to

  2. Create your custom icon; there are plenty of free tools on the internet like: https://convertio.co/png-ico/ or https://convertico.com

  3. Create a file called desktop.ini within it, with this minimal content:

    [.ShellClassInfo]
    IconResource=<PathToYourIconFile(.ico,.dll)>,0
    

    NOTES: 1. The 0 at the end marks the IconIndex within your icon file, in case it contains multiple icons within 1 file, but for regular .ico files 0 should be the default. 2. I recommend placing your custom icon within the same folder, that allows you to use a relative path like so IconResource=.\YourIcon.ico,0. This means your custom icon won't break when you move your folder!

  4. And now for Gotcha #1: For Windows to properly process your desktop.ini file you need to mark the folder itself as read-only! I will quote Camilo Martin here: makes no sense and sounds stupid, so you know it's legit... You can achieve this by opening a command prompt in the parent folder and call attrib +r . (You can verify that it worked by calling attrib /d in the parent folder and you should see a R in front of the folder).

  5. Some people say that you also need to make sure that both the desktop.ini and the icon are marked as hidden and system. Based on my tests this was not necessary(!) to achieve the desired effect, but you can do so by calling attrib +s +h desktop.ini and attrib +s +h <YourIconFile>, respectively, if you encounter issues.

So far so good...ok, moving on...

Part 2: How do fix custom icons on network shares

Disclaimer: This may be very depended on your specific network share, in my case I am using a Samba (SMB) share hosted on a Linux server (Docker image: ghcr.io/jtagcat/samba)

  1. And now for Gotcha #2: When hosting your network share on Linux you get cross-platform compatibility issues, as Windows and Linux store file/folder attributes differently. To ensure Samba persists the Windows attributes make sure that store dos attributes = yes is set. (For me it worked both in [Global] and within a specific share, so pick your poison)

  2. And now for Gotcha #3: Since some recent update, Windows prevents making network calls to load content in the shell/explorer by default, so when your icon is located on a network share it will simply not load it. To fix this you need to create a new registry key, by calling the following command from an elevated command prompt:

    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer" /V "EnableShellShortcutIconRemotePath" /t REG_DWORD /d 1 /f
    

    Source: https://learn.microsoft.com/en-us/answers/questions/1162419/shortcut-icon-blank-when-ico-file-is-located-on-a?orderBy=Newest

  3. If after all this your custom icons are still broken (as they were for me), get ready for Gotcha #4: When trying to call attrib +r <Folder>, the read-only flag simply didn't change at all for my existing folders (that contained my original custom icon setup), creating new folders did not suffer from this problem and can be customized without issue. Inspecting the folders carefully, on the linux host, using getfattr -n system.ntfs_attrib_be /Path/To/Parent/Folder/* (first run apt install attr), I found that the broken folders had the following attribute set 0sAAAAFA== while the newly created folders were defined as 0sAAAAMA==. These are base64 encoded value, but only the last 2 letter here are relevant: FA=00010100 and MA=00110000 (https://cryptii.com/pipes/base64-to-binary). These bitmask are define as such (right->left):

    1. Read-Only
    2. Hidden
    3. System
    4. Volume ID
    5. Directory
    6. Archive
    7+: Unused
    

    After running sudo setfattr -n system.ntfs_attrib_be -v 0sAAAAMA== /Path/To/Broken/Folder I could finally call attrib +r <Folder> from Windows to have my icons appear! Thus for some reason my folders were marked as System which probably prevented me from altering them (even as administrator). Also when I set the +r flag from cmd, strangely enough the ntfs_attrib_be flag read-only is unchanged. Strange...but it works.

Post-Mortem: If after all of these steps it seems like this is way too unnecessarily complicated...you're right and I agree...this is insane. But for those that value organization and customization I hope this helps and saves you a few hours/days of frustrating debugging!

Now take a deep breath...and have a lovely day!🌞

2
  • 1
    Welcome to Super User! Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
    – DavidPostill
    Nov 17, 2023 at 12:29
  • Dear DavidPostill, thank you for your feedback; this is my first answer here and since both questions boil down to the same problems I thought I answer them both to hopefully help out more people. What is the best practice for linking another post to this answer? I don't think that closing either makes sense, as the top of this question indicates this question was asked first, but the other also has valuable information.
    – H.Basien
    Nov 17, 2023 at 12:41
0

Personally all of the above solutions did not work for me (Windows 10 Pro, Version 10.0.19045 Build 19045).

I found a solution in MS Community at: https://answers.microsoft.com/en-us/windows/forum/all/win10-custom-folder-icons-desktopini-not-working/14ed4ffe-313e-4799-918a-449cf7edb686

The answer was provided by "MartinWalker6", on 1st of November 2022 for Windows 11 but I confirm it also works for W10, at least for the current release of my W10 (see above). It requires Win Pro since it makes usage of the Group Policy Editor (but it seems to me that I read somewhere else that it is possible to install the Group Policy Editor on a Home edition).

I quote below his answer that worked for me, in case the link fails someday:

If you are running Windows 11 Pro you can use the Group Policy Editor to fix this by enabling the group policy for "Allow the use of remote paths in file shortcut icons" in Computer Configuration -> Administrative Templates -> Windows Components -> File Explorer.

Enabling this has fixed it on each computer affected.

If you are running Windows 11 Home, there are a number of ways to install the Group Policy Editor to be able to do this.

You must log in to answer this question.

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