28 lines
1012 B
Batchfile
28 lines
1012 B
Batchfile
|
@echo off
|
||
|
setlocal
|
||
|
|
||
|
:: 设置几个环境变量以便于后续使用
|
||
|
set SCRIPT_DIR=%~dp0
|
||
|
set SHORTCUT_NAME=webp_to_png.lnk
|
||
|
set ICON_PATH=%SCRIPT_DIR%webp_to_png\program_data\favicon.ico
|
||
|
set TARGET_PATH=%SCRIPT_DIR%webp_to_png.exe
|
||
|
set WORKING_DIR=%SCRIPT_DIR%
|
||
|
set SHORTCUT_PATH=%USERPROFILE%\Desktop\%SHORTCUT_NAME%
|
||
|
|
||
|
:: 创建一个 VBS 脚本来生成快捷方式
|
||
|
echo Set oWS = WScript.CreateObject("WScript.Shell") > "%TEMP%\CreateShortcut.vbs"
|
||
|
echo sLinkFile = "%SHORTCUT_PATH%" >> "%TEMP%\CreateShortcut.vbs"
|
||
|
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> "%TEMP%\CreateShortcut.vbs"
|
||
|
echo oLink.TargetPath = "%TARGET_PATH%" >> "%TEMP%\CreateShortcut.vbs"
|
||
|
echo oLink.IconLocation = "%ICON_PATH%" >> "%TEMP%\CreateShortcut.vbs"
|
||
|
echo oLink.WorkingDirectory = "%WORKING_DIR%" >> "%TEMP%\CreateShortcut.vbs"
|
||
|
echo oLink.Save >> "%TEMP%\CreateShortcut.vbs"
|
||
|
|
||
|
:: 运行生成的 VBS 脚本
|
||
|
cscript /nologo "%TEMP%\CreateShortcut.vbs"
|
||
|
|
||
|
:: 清理临时生成的 VBS 脚本
|
||
|
del "%TEMP%\CreateShortcut.vbs"
|
||
|
|
||
|
endlocal
|