I'd really appreciate some advice on how to make the following work.
I am using a CMD script to make a shortcut LNK file. It does this by echoing out various commands to a VBS file using >>
.
One of the commands is called oLink.Arguments
.
Currently my working example is set as follows:
oLink.Arguments = "/run /tn Custom_Scripts\TaskName" >>%VBSScript%
This only works if there are no spaces in Custom_Scripts\TaskName
. I need, however, the script to work with task names which contain spaces.
Manually all I need to do is place quotes as follows:
"Custom_Scripts\TaskName"
However when set, the command line cannot output the line as there are quotes present already.
Example:
oLink.Arguments = "/run /tn "Custom_Scripts\TaskName"" >>%VBSScript%
Doesn't work. I've tried various things like triple quotes or escaping quotes but no luck.
I apologise if I'm not explaining this to well but hope someone out there may have a solution or idea which they're willing to share with me.
Edit:
From my comment underneath this answer.
SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "C:\TechTools\Scripts\Create_an_elevated_shortcut\myshortcut.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "C:\TechTools\O&O\ShutUp10\OOSU10.exe" >> %SCRIPT%
echo oLink.Arguments = "/run /tn Custom_Scripts\Task_Name" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
This works as long as there are no spaces in the "Custom_Scripts\Task_Name"
.