# How to make desktop.ini work on network locations

desktopnetwork-shares

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?

## 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