@echo off
set "url=https://www.baidu.com"
set "linkName=百度.exe.url"
set "savePath=%USERPROFILE%\Desktop\%linkName%"

:: 关键修正点:使用脚本所在目录的绝对路径
set "IconFile=%~dp0care.ico"
set "IconIndex=0"

echo [InternetShortcut] > "%savePath%"
echo URL=%url% >> "%savePath%"
echo IconIndex=%IconIndex% >> "%savePath%"
echo IconFile=%IconFile% >> "%savePath%"

:: 清理图标缓存
taskkill /f /im explorer.exe >nul 2>&1
del /a /q "%LOCALAPPDATA%\IconCache.db" >nul 2>&1
start explorer.exe

 

 

*注意:ico图片要和bat文件放在同一个目录喜爱,我这边目录如下:

 


 

第二种,增加需求要每次都在新窗口打开

@echo off
set "targetPath="C:\Program Files\Google\Chrome\Application\chrome.exe" :: 目标程序路径
set "arguments=--new-window https://www.baidu.com" :: 参数(如强制新窗口)
set "shortcutName=百度.lnk" :: 快捷方式名称
set "iconFile=%~dp0care.ico" :: 图标文件路径
set "savePath=%USERPROFILE%\Desktop\%shortcutName%" :: 保存路径

:: 使用 PowerShell 创建快捷方式
powershell -Command "$ws = New-Object -ComObject WScript.Shell; $sc = $ws.CreateShortcut('%savePath%'); $sc.TargetPath = '%targetPath%'; $sc.Arguments = '%arguments%'; $sc.IconLocation = '%iconFile%,0'; $sc.Save()"

echo 快捷方式已创建到桌面!
pause

 

posted on 2025-04-11 15:36  JerryBolgs  阅读(133)  评论(0)    收藏  举报