How to Create/Assign Custom Folder Icon via Command Prompt

What I like to do is create folders and assign image/cover arts as the folders thumbnail, rather than generating the standard folder icon. I do this very often (basically every folder I can bother to find an image for).

I setup a script/.bat file so that I can place any image file into the folder, press the hotkey, then it will run a program (Pixillion) to convert the image to a .Ico file and hide it.
It will also create a desktop.ini file, like what Windows 10 does when you manually set the folder’s custom icon.


after my script is done, Windows 10 recognizes that I have a custom folder icon (because it doesn’t use the generated one, showing the icons inside the folder), however it instead shows an empty folder as the icon.
If I place a .url file into the folder, then rename it (manually, does not work from cmd), the folder icon will refresh/update correctly to my custom icon.

What I’m looking for, is to get this done without this final manual step.
To set and update the icon automatically.


Customization via a desktop.ini file requires not only the file, but also the folder has to have its System or ReadPnly attribute set. That’s the “Switch” that tells the OS to look for & process the folder’ s desktop.ini file. When Windows sets a custom icon, it sets tieh ReadOnly attriubte — this can be verified by adding the Attributes column to a Detail view in Explorer. In PowerShell, if you within the folder/directory, y use:

### View attriubtes
(Get-Item .).Attributes
# OUtput
PS C:\...\Customized FOlder>( Get-Item . ).Attributes
ReadOnly, Directory

### Set ReadOnly attriubtes
(Get-Item .).Attributes += 'ReadOnly'
# no output when successful

### Clear ReadOnly attriubtes
(Get-Item .).Attributes -= 'ReadOnly'
# no output when successful

enter image description here

Attribue cleared & view refreshed:

enter image description here

…and back again:
enter image description here

Source : Link , Question Author : Megame , Answer Author : Keith Miller

Leave a Comment