Changing folder icons on an SMB share

Dmitchell

Cadet
Joined
May 6, 2023
Messages
5
I am new to TrueNas Storage. I have a system running and I have copied the folders from a USB connected drive over to the NAS. One the USB drive I can change the icon of the folder under customize. Under the NAS storage that option does not appear.
Is this type of thing not possible on the NAS? Is there a permissions issue I have not discovered? Might there be another way to have a folder on the NAS stand out in a unique way from other folders?
Thanks in advance for any help.
 
Joined
Jun 15, 2022
Messages
674
I'm going to guess that's a feature of your operating system that's supported by the type of file system you're using. (that's not a super-helpful answer, but we don't know what system and setup you're running on)
 

Dmitchell

Cadet
Joined
May 6, 2023
Messages
5
I'm going to guess that's a feature of your operating system that's supported by the type of file system you're using. (that's not a super-helpful answer, but we don't know what system and setup you're running on)
I am on Windows 10. I have 6 8tb drives attached using the USB ports. The idea here was to create the NAS and copy the folders and files from Drive H to a file named H Drive on the NAS. That all worked, however this is where I can no longer change the folder Icons. That option is not on the Customize tab on any of the folders on the NAS.
All we really need to do is find a way for some particular folders to stand out from all of the others on the NAS. The Windows route worked for us but if that is not supported so we may be looking for other options.
I was just wondering if this was a permissions issue or the fact that it is network storage that the option no longer works.
 
Joined
Jun 15, 2022
Messages
674
This might work: Rename your folder image folder.jpg and place it in the shared folder (this might require a restart of the client, and/or a dump of the cached drive icons). If it does work (which for me it no longer does-even on Windows Server-due to security updates), repeat the steps for each image/folder combination on each workstation.

There are a lot of versions of Windows (more so with different updates and security patches/restrictions), so I don't know all the details as it applies to your situation, but the above is what you want to do if it works. If it doesn't, in my system notes I found the following:
  1. Right-click --> Properties --> Customize ---> Change Icon is not available on SMB shares.
  2. Right-click --> Properties --> Customize ---> Change Picture has no effect, even if the picture (JPG or PNG) is named folder.jpg and in the root directory of the share.
  3. Desktop.ini is NOT processed by windows for SMB shares, because Linux interprets the (folder's) "Read Only" bit differently, and reports it back to Windows incorrectly:
    • In Linux, Read Only means Read Only
    • In Windows, Read Only (with folders only) means process Desktop.ini
  4. There is supposed to be a registry setting that forces Desktop.ini processing by using the "System" [super-hidden] flag instead of "Read Only" but it may not work as expected.
  5. The lack of Desktop.ini processing on SMB breaks many other things that are locally available, not just folder icons: Symbolic Links and "personalized name spaces" also don't function.
  6. It should be possible to create indirect links to access the SMB folders and give those custom icons instead, but that causes multiple other problems:
    • Short-cut links are evaluated and cached by default in Windows when opening the parent folder, causing "massive" delays in explorer if a folder contains shortcuts to slow or sleeping network shares.
    • Shortcuts in windows are absolute, not relative ergo not portable. This creates a lot of maintenance should the target root path change. Windows also has a habit of automatically converting environment vars to absolute links, defeating any attempt at working around this.
    • Their "Distributed Link Tracking Client" service could potentially make a mess of things.
  7. The best way to implement relative links in Windows (which is not a great idea) is to use VBS script. In native (text) form, the VBS script will not have a custom icon, but you can assign a custom icon to the EXE file if you compile it.
That is a lot of work though, and the script will create "untrusted" warning messages every time you launch it from a network, unless the script is local or you sign the script.
VBS Relative Link example: ============================ ' This is a VB Script, which emulates a RELATIVE file link/shortcut in Win XP ' ' 1) The first line declares an untyped variable ==> objshell ' ' 2) The second line instantiates a new object derived from ==> Shell.Application ' ' 3) The third line invokes the object's method ==> ShellExecute ' ' with the following parametters: "target path" ' "target's arguments" ' "starting directory" ' "action verb" ' Initial window mode: 0 = Hidden Window ' 1 = Normal Window ' 2 = Minimized ' 3 = Maximized ' 4 = Most recent size and position, keep active window active ' 5 = Current size and position ' 6 = ' 7 = Minimized, keep active window active ' 10 = Default state specified by target application ' ' 4) The last line frees/destroys the shell object ' ' dim objShell set objShell = CreateObject("Shell.Application") objShell.ShellExecute _ "..\..\..\SomePath_Three_Dirs_UP_etc" ,_ "" ,_ "" ,_ "open" ,_ 1 set objShell = nothing ===============================================================
 
Last edited:

Dmitchell

Cadet
Joined
May 6, 2023
Messages
5
Do you know if TrueNAS has any built in way to change the look of the folder Icons? I am just looking for some way to may some of the folders look different than the others.
Thanks
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Do you know if TrueNAS has any built in way to change the look of the folder Icons?
Yes, it doesn't.

Answering the question you meant to ask: No. There is no such feature.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I don't believe there is any built in way. The way folder icons are presented is a display affectation generated by your desktop GUI, and it looks like Microsoft buried this into the folder attributes. You might consider looking at the instructions here:


But beware they're trying to sell you something, and this may not actually be helpful.
 
Joined
Jun 15, 2022
Messages
674
I spent some time on a Windows Server and Workstation to figure this out, and with the current network security permissions it does not look feasible.

I converted a graphic into an .ico file, assigned the icon to a local folder test and it worked. Doing the same on a network folder test, copying and editing desktop.ini for the correct paths, having folder.ico in the test folder, permissions, etc...all did not work for the network drive.

It will work for a local drive with the subst command, though again that's local.

It looks like the issue is stemming from changing from a local USB drive to a networked drive under Windows.
 

Dmitchell

Cadet
Joined
May 6, 2023
Messages
5
Is there a Windows solution for a NAS? If so would that work better for this file Icons issue I am facing?
 
Joined
Jun 15, 2022
Messages
674
There isn't a solution I know of, Windows or otherwise. The paid software @jgreco mentioned might work (I haven't tried it).

You can try what's listed above and it might work for a limited amount of time until a security patch or upgrade is applied, though my systems are current and I could not find a way to do it, and I'm in a mostly Windows environment so if there was any hope of it working it should work there.

Might there be another way to have a folder on the NAS stand out in a unique way from other folders?
Folder names can be started with a dash or underline, though an underline might cause them to appear as hidden on some computers--generally an underline isn't an issue, but if it for some reason a folder doesn't show up on some systems that's why (generally UN*X boxes set to hide files that start with an underline).

My company has a similar need to highlight some folders, hence my taking a serious look into this. We usually use an underline and have not experienced negative consequences.
 
Last edited:

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
There isn't a solution I know of, Windows or otherwise. The paid software @jgreco mentioned might work (I haven't tried it).

And just to be clear, I was not recommending it. I just happened across it when seeing if Samba had any specific support for this (since this is really a Samba/Windows question).
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Mac OS will let you assign custom icons to folders regardless of location and sharing protocol. If not supported by extended attributes it will create silly dot-files to achieve the same effect. If Windows cannot do this, I call "tough shit". Sorry. It really is the responsibility of the presentation layer and hence the desktop OS to manage this somehow.
 
Joined
Jun 15, 2022
Messages
674
Mac OS will let you assign custom icons to folders regardless of location and sharing protocol. If not supported by extended attributes it will create silly dot-files to achieve the same effect. If Windows cannot do this, I call "tough shit". Sorry. It really is the responsibility of the presentation layer and hence the desktop OS to manage this somehow.
A lot of the problem is the way the monolithic Windows kernel works, and how security doesn't. The recent "hot Windows exploit" is to label an executable as a screen saver, e-mail it to an unsuspecting user and let Windows sort out what it really is, which in this example is a virus. This has long been a Windows issue where the OS looks at the file header and then "does something" based on what the file underneath actually is. That's pretty sketchy as virus scanners scan executable files and here we can package an executable as a text file and it won't get scanned, or recently as a screen saver. The benefit of the way Windows is written in general is "it's very fast and compatible with most everything and anything."

What that means in context is infecting a Windows computer is as easy as labeling an executable as an image, buying ad space and putting that image up in an advertisement on thousands of websites, then watching people who are surfing valid sites get infected as their browser downloads the ad image and Windows runs it as an executable. Wow, right?

In this case a virus could spread by writing itself to a network drive, labeling itself a folder icon, then being run by everyone who sees that mapped drive (like most if not all of the company). That's pretty crippling.

To combat this only local resources connected to your PC can use files you've already put on your PC as custom folder icons, which is why USB drives can have custom folder icons but remote folders located on the network cannot. --Well, unless someone hacks the OS and jams it up, which is what often happens to get things working under Windows, like folder icons. Could this expose your whole infrastructure to easy takeover? Maybe, depending on how well the third-party software is written and how exactly is plugs into the OS, or "hooks into the OS and bypasses OS 'security.'"
 

Rockel83

Cadet
Joined
Nov 8, 2023
Messages
4
Maybe it's a bit late for you guys. But I was facing the same problem, not being able to change the folder icon's on a shared network drive.

However, what seems to work for me so far is to change the folder icon in Windows and than copy/move it to the network drive. And just replacing the files to that specific folder then.

So far it seems the icon keeps retained. Even after restart NAS or PC. I'm not sure yet if my PC will still recognize the icon after re-installing Windows. But so far it seems to work (with a little workaround).

I was actually checking the internet if there was an easier work around and that I was overseeing something.
 
Joined
Jun 15, 2022
Messages
674
@Rockel83 : That sounds like a Windows cache on the local PC is not being updated to reflect the changes.

From a user standpoint custom folder icons seems simple, from a corporate standpoint it's not such a good idea for many reasons. Perhaps that's why Windows allows it on a local PC and not on a network.
 

Rockel83

Cadet
Joined
Nov 8, 2023
Messages
4
@Rockel83 : That sounds like a Windows cache on the local PC is not being updated to reflect the changes.

From a user standpoint custom folder icons seems simple, from a corporate standpoint it's not such a good idea for many reasons. Perhaps that's why Windows allows it on a local PC and not on a network.

I was actually expecting this too.

But just did a test.
- I've created folders with custom icons on my Windows-11 laptop
- Copied those custom folders to my NAS
- The folders retained it's icon. Even after restarting laptop or NAS.

My test:
- Took my old Windows-7 laptop out of the closet (wasn't start up for over a year, so it would be the first time since then to acces the NAS).
- Went to the folder on the NAS, which contained the customized folders (made on the Windows-11 laptop).
- Just saw folders with customized icon's. Although slightly different icon's, since Windows-7 has different base icon's then Windows-11. But all were in the same context like: network folder/ my documents/ folders with different colors.

So it seems to work with this workaround.
 

Rockel83

Cadet
Joined
Nov 8, 2023
Messages
4
folder test.jpg
 
Joined
Jun 15, 2022
Messages
674
@Rockel83 : There's a security hole... good job in finding it.

I found a handy one with launching CMD windows, eventually a forced upgrade removed it; perhaps use but don't rely on it working because one day it may not.

I found another one with pining files to the task bar as shortcuts, eventually MS added that as a feature in W10, so it goes both ways.
 

Rockel83

Cadet
Joined
Nov 8, 2023
Messages
4
@Rockel83 : There's a security hole... good job in finding it.

I found a handy one with launching CMD windows, eventually a forced upgrade removed it; perhaps use but don't rely on it working because one day it may not.

I found another one with pining files to the task bar as shortcuts, eventually MS added that as a feature in W10, so it goes both ways.

Was just experimenting a bit with it.
Once customizing a folder in Windows, there will be that hidden system file "desktop.ini" generated. So actually tried to copy that file from a customized folder on the Windows system to the NAS (Nieuwe map & Nieuwe map (2)) in the pictures above. But this didn't changed anything. Also not on Windows itself as you can see in the same picture. Couldn't find a "path" in the *.ini file of that specific folder. But seems it's somehow registered to the customized folder itself. It only shows the path of the icon file and showing the corresponding icon number:

[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,316
[ViewState]
Mode=
Vid=
FolderType=Generic

But that desktop.ini file should probably be the reason why other Windows system will recognize the customized folder (with the custom icon) on a network drive. This *.ini file is not existing in a non-customized folder. And while there's no option in Windows to change the folder Icon of the folder on a network drive, there will be no *.ini file created.

So just copying a customized folder (containing that own "registered" desktop.ini file of course) seems to be a workaround.
Although it may be a bit inconvenient on existing configurations, since you first need to copy a folder to the network drive. And then copy/move files to that folder.
I did not have tried it yet. But I suppose it would be easy changing the icons later on, using that once created and "registered" *.ini file. By just changing the icon number (or path if you want to use another icon file/database.

Maybe it would be a bit more convenient being able to somehow copy that "desktop.ini" file and find a way to get it "registered" to that specific folder. But this is outside of my understanding at the moment.

Maybe there should be a some kind of way to change the folder preferences. To change the "FolderType" for example. So a Windows system knows that it's a customized folder and that it needs to read the desktop.ini file inside. But that's just a thought...
 
Joined
Jun 15, 2022
Messages
674
The icon location is specified in the desktop.ini file, which is good.

The not-so-good news is it does not work with custom icons.
  • create custom icons and store them in a folder on the local machine: I:\.icons
  • create a local folder: I:\drafting
  • on the folder: Right-Click - Properties - Customize - Change Icon - Browse: I:\.icons\drafting.ico
Result: Works.

Edit: I:\drafting\desktop.ini
  • Change: IconResource=I:\.icons\drafting-32.ico,0
  • to: IconResource=U:\.icons\drafting-32.ico,0
U is a network drive, and this will not work because the icon file is located on a network share. The same goes for:
  • \\SVR01\Users\Hedgehog\.icons\drafting-32.ico,0
The outcome is the file containing the icon graphic must be located on a drive connected to the local machine. A script could be written to auto-download updates to the C drive local machines, or if all machines use a local data drive such as D then the files could reside on D, however any machine without "D:\.icons" would not see the custom folder icon. Like most Microsoft things, it becomes a mess to manage; does your Linux box have D:\.icons? Probably not.
 
Top