编译时生成快捷方式
某些程序需要启动时添加参数,如何在编译后生成带参数的快捷方式
1项目中添加如下bat,原理为生成临时vbs,执行后删除
@echo off
echo Dim WshShell,Shortcut >> tmp.vbs
echo Dim shortCutPath,shortCutTarget,par,fso >> tmp.vbs
echo shortCutPath = %1 >> tmp.vbs
echo shortCutTarget = %2 >> tmp.vbs
echo par = %3 >> tmp.vbs
echo Set fso = CreateObject("Scripting.FileSystemObject") >> tmp.vbs
echo Set WshShell = WScript.CreateObject("WScript.Shell") >> tmp.vbs
echo Set Shortcut = WshShell.CreateShortCut(shortCutPath) >> tmp.vbs
echo Shortcut.TargetPath = shortCutTarget >> tmp.vbs
echo Shortcut.Arguments = par >> tmp.vbs
echo Shortcut.Save >> tmp.vbs
echo Set Shortcut = Nothing
"%SystemRoot%\System32\WScript.exe" tmp.vbs
@del /f /s /q tmp.vbs
2在项目build event中添加"$(ProjectDir)Config.bat" "$(TargetDir)Config.LNK" "$(TargetPath)" "config",执行bat,参数1为快捷方式路径,参数2为快捷方式目标路径,参数3为启动参数