nikfilippas
nikfilippas

Reputation: 105

How to change existing folder's icon via Command Line? (Windows 10)

I have a folder on my desktop and 12 different icons. I want to create a scheduled task with Task Scheduler that runs as long as my PC is on and changes the icon of the folder every 15 minutes.

I have done my research and I found this code:

`attrib -h -r c:\test\desktop.ini
echo [.ShellClassInfo] >C:\test\desktop.ini
echo IconFile=%SystemRoot%\system32\shell32.dll>>C:\test\desktop.ini
echo IconIndex=0 >>C:\test\desktop.ini
attrib +h +r c:\test\desktop.ini
attrib +r c:\test`

However, I have no clue on how to implement/amend this to execute the task that I want to. I would not like a Batch file appearing on my Desktop.

Any help would be appreciated. Thanks.

Upvotes: 3

Views: 9921

Answers (2)

Majid
Majid

Reputation: 517

You can use below script that I found it here.

If [%1] == [] goto :eof
ECHO [.ShellClassInfo] >%1\desktop.in
ECHO IconResource=C:\icon.ico,0 >>%1\desktop.in
move %1\desktop.in %1\desktop.ini
attrib +S +H %1\desktop.ini
attrib +R %1

Upvotes: 1

Shadowforce62
Shadowforce62

Reputation: 31

I was able to make a working model here:

Set DriveLetter=C    
Set Pathing=test    
Set IconPath=users\username\desktop\icon.ico    
attrib -s -h -r %DriveLetter%:\%Pathing%\desktop.ini    
echo [.ShellClassInfo] >%DriveLetter%:\%Pathing%\desktop.ini    
echo IconFile=%DriveLetter%:\%IconPath%>>%DriveLetter%:\%Pathing%\desktop.ini    
echo IconIndex=0 >>%DriveLetter%:\%Pathing%\desktop.ini    
attrib +s +h +r %DriveLetter%:%Pathing%\desktop.ini    
attrib +s +r %DriveLetter%:\%Pathing%    
pause

Please note the following:

This doesn't require the need for "DriveLetter" I just like adding that to my scripts (Though having the drive letter specified is required, you just don't need the extra option it can be merged in with the path[Pathing] Option)

DriveLetter= The drive you want it on

Pathing= the path to the folder in question you wish to change

Iconpath= the full path to the icon's location

The result is I have a folder located @ E:\test\ that has the icon in question

you should be able to run that code and get output by only editing the top 3 lines, or you could write it in manually.

Upvotes: 3

Related Questions