How can I make desktop.ini work on network locations?

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?


Solution 1:

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

Solution 2:

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)

Solution 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