如何通过命令行更改现有文件夹的图标? (Windows 10) [英] How to change existing folder's icon via Command Line? (Windows 10)
问题描述
我在桌面上有一个文件夹和12个不同的图标。我想使用Task Scheduler创建一个计划任务,该任务在PC开启时一直运行,并每15分钟更改一次文件夹的图标。
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.
推荐答案
我能够在这里建立一个可行的模型:
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
请注意以下几点:
这不需要 DriveLetter,就像将其添加到脚本中一样(尽管需要指定驱动器号,但是您不需要它可以与path [Pathing]合并的额外选项。选项)
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 = Th在您想要的驱动器上
DriveLetter= The drive you want it on
Pathing =要更改的文件夹的路径
Pathing= the path to the folder in question you wish to change
Iconpath =图标位置的完整路径
Iconpath= the full path to the icon's location
结果是我有一个位于@ E:\test located的文件夹,其中有相关图标
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.
这篇关于如何通过命令行更改现有文件夹的图标? (Windows 10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!