我不知道如何编写这个批处理,以便所有引号都在正确的位置并创建快捷方式文件。我使用上述信息作为参考。我的最终目标应该是
Target: %COMSPEC% /c start "" "E:\PinballEmporium\Core\RetroFE.exe"
这是我编写的批处理,如果我删除“start”一词后的所有内容,它将写入快捷方式文件,但显然这不是我所需要的全部。(这是从“E:\PinballEmporium”启动的)
@echo off
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\Pinball Emporium.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
REM %COMSPEC% /c start "" "E:\PinballEmporium\Core\RetroFE.exe"
echo oLink.TargetPath = "%%COMSPEC%% /c start "" "%cd%\Core\RetroFE.exe"" >> %SCRIPT%
REM echo oLink.Arguments="%cd%\Core\RetroFE.exe" >> %SCRIPT%
echo oLink.IconLocation="%cd%\PEICON.ico" >> %SCRIPT%
echo oLink.WorkingDirectory="%cd%" >> %SCRIPT%
echo oLink.WindowStyle="0" >> %SCRIPT%
echo oLink.Description="Shortcut for Pinball Emporium"
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
答案1
您可以尝试一下这个批处理文件:
@echo off
Title Batch Shortcut Creator
Set "ShortcutName=Pinball Emporium"
Set "TargetPath=E:\PinballEmporium\Core\RetroFE.exe"
Set "IconLocation=%cd%\PEICON.ico"
Call :Create_Shortcut "%ShortcutName%" "%TargetPath%" "%IconLocation%"
EXIT
REM -----------------------------------------------------------------------------
:Create_Shortcut
Set "VBS_Shortcut=%temp%\%~n0.vbs"
>"%VBS_Shortcut%" (
echo Call Create_Shortcut("%~1","%~2","%~3"^)
echo Sub Create_Shortcut(ShortcutName,TargetPath,IconLocation^)
echo Dim objShell,DesktopPath,objShortCut
echo Set objShell = CreateObject("WScript.Shell"^)
echo DesktopPath = objShell.SpecialFolders("Desktop"^)
echo Set objShortCut = objShell.CreateShortcut(DesktopPath ^& "\" ^& ShortcutName ^& ".lnk"^)
echo objShortCut.TargetPath = chr(34^) ^& TargetPath ^& chr(34^)
echo objShortCut.IconLocation="%~3"
echo objShortCut.Save
echo End Sub
)
cscript //nologo "%VBS_Shortcut%" "%~1" "%~2" "%~3"
If Exist "%VBS_Shortcut%" Del "%VBS_Shortcut%"
Exit /B
REM ------------------------------------------------------------------------------