Batch file 当图标位于快捷方式旁边时,如何为快捷方式文件创建图标

Batch file 当图标位于快捷方式旁边时,如何为快捷方式文件创建图标,batch-file,shortcut,Batch File,Shortcut,我想为快捷方式文件选择一个图标 文件必须在每台计算机上运行,但图标文件路径在每台计算机上可能不同 我尝试了以下代码来更改图标属性: "%windir%\system32\cmd.exe /c echo "%CD%\1.ico"" 但它不起作用 所以基本上,您要做的是创建一个带有自定义图标和路径的快捷方式,而不需要用户交互,对吗 我们可以使用VBS代码来执行此任务。我相信在Windows 8/8.1/10中,情况略有不同,如果有任何问题,请告诉我,但是,正

我想为快捷方式文件选择一个图标

文件必须在每台计算机上运行,但图标文件路径在每台计算机上可能不同

我尝试了以下代码来更改图标属性:

"%windir%\system32\cmd.exe /c echo "%CD%\1.ico""
但它不起作用


所以基本上,您要做的是创建一个带有自定义图标和路径的快捷方式,而不需要用户交互,对吗

我们可以使用VBS代码来执行此任务。我相信在Windows 8/8.1/10中,情况略有不同,如果有任何问题,请告诉我,但是,正如我记得的,Windows 7中的VBS:

Set WshShell = CreateObject ("Wscript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") \\ You can delete the code and just put like 'strDekstop = "X:\User\Desktop"' if you want.
Set Shortcut = WshShell.CreateShortcut(strDesktop + "\ShortcutName.lnk")
Shortcut.WindowStyle = "3" 
Shortcut.IconLocation = "X:\YourIcon.ico"
Shortcut.TargetPath = "X:\YourPath\OrFolder\yourarchive.exe"
ShortCut.Hotkey = "ALT+CTRL+F" // You can just delete this line if you don't want a hotkey.
ShortCut.Save
如果你想要更自动化的东西,我们可以把它变成一个蝙蝠脚本没有问题

快捷方式生成器.bat

@echo off
@chcp 1252 >nul
:: By Katorn Hypno
:: Never use quotation marks.
:loop
:: Configs and info above.

:: Command section bellow

:: Asking for directions.
:: Don't forget the executable name and the .exe.
set /p targetpath=Target Path+Executable: 
:: Don't forget the .ico at the end with the icon name.
:: You can put lnklocation and the iconlocation on top of ":loop" for a single ask.
set /p iconlocation=Icon Location: 
set /p lnklocation=Shortcut Location: 
set /p lnkname=Shortcut Name: 

:: Writing VBS file and creating Shortcut.
echo Trying to write...
set katorn=%random%
echo >>%katorn%.vbs Set WshShell = CreateObject ("Wscript.Shell")
echo >>%katorn%.vbs strDesktop = "%lnklocation%"
echo >>%katorn%.vbs Set Shortcut = WshShell.CreateShortcut(strDesktop + "\%lnkname%.lnk")
echo >>%katorn%.vbs Shortcut.WindowStyle = "3" 
echo >>%katorn%.vbs Shortcut.IconLocation = "%iconlocation%"
echo >>%katorn%.vbs Shortcut.TargetPath = "%targetpath%"
echo >>%katorn%.vbs ShortCut.Save
:: You can comment the next line if you don't want to execute the VBS files.
cscript %katorn%.vbs
:: You can uncommment the next line if you want to delete after executing.
:: del /q /f %katorn%.vbs
echo Done.
goto loop
@echo off
@chcp 1252 >nul
set /p folder=VBS archives folder:
:: Uncomment the code bellow to try every possibility.
:: set /l %%w in (0,1,99999) do (
:: cscript %%w.vbs
:: )
:: echo All trys got executed. 99999.
for /d %%w in (%folder%\*) do (
cscript %%w.vbs
 )
echo Done.
pause;
快捷方式阅读器.bat

@echo off
@chcp 1252 >nul
:: By Katorn Hypno
:: Never use quotation marks.
:loop
:: Configs and info above.

:: Command section bellow

:: Asking for directions.
:: Don't forget the executable name and the .exe.
set /p targetpath=Target Path+Executable: 
:: Don't forget the .ico at the end with the icon name.
:: You can put lnklocation and the iconlocation on top of ":loop" for a single ask.
set /p iconlocation=Icon Location: 
set /p lnklocation=Shortcut Location: 
set /p lnkname=Shortcut Name: 

:: Writing VBS file and creating Shortcut.
echo Trying to write...
set katorn=%random%
echo >>%katorn%.vbs Set WshShell = CreateObject ("Wscript.Shell")
echo >>%katorn%.vbs strDesktop = "%lnklocation%"
echo >>%katorn%.vbs Set Shortcut = WshShell.CreateShortcut(strDesktop + "\%lnkname%.lnk")
echo >>%katorn%.vbs Shortcut.WindowStyle = "3" 
echo >>%katorn%.vbs Shortcut.IconLocation = "%iconlocation%"
echo >>%katorn%.vbs Shortcut.TargetPath = "%targetpath%"
echo >>%katorn%.vbs ShortCut.Save
:: You can comment the next line if you don't want to execute the VBS files.
cscript %katorn%.vbs
:: You can uncommment the next line if you want to delete after executing.
:: del /q /f %katorn%.vbs
echo Done.
goto loop
@echo off
@chcp 1252 >nul
set /p folder=VBS archives folder:
:: Uncomment the code bellow to try every possibility.
:: set /l %%w in (0,1,99999) do (
:: cscript %%w.vbs
:: )
:: echo All trys got executed. 99999.
for /d %%w in (%folder%\*) do (
cscript %%w.vbs
 )
echo Done.
pause;
希望这有帮助,
K.