I know there are many posts on this issue but there is a minor twist to what I need to do.
I can figure out how to create a shortcut with an argument like this:
"C:\Program Files\My App\App.exe" /s
But I need to apply the path of a file wrapped in "" as argument like this:
"C:\Program Files\My App\App.exe" "c:\Data\File.ext"
Note the double quotes.
I can't find any VBscript examples illustrating this behaviour.
This is what I've based my current script on.
@echo off set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "%USERPROFILE%\Desktop\myshortcut.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% echo oLink.TargetPath = "D:\myfile.extension" >> %SCRIPT% echo oLink.Save >> %SCRIPT% cscript /nologo %SCRIPT% del %SCRIPT%