CreateShortCut "$InstDir\Prog.lnk" "$PROGRAMFILES\DOS\DOSEmu.exe" "-conf $InstDir\DosConfig.conf"
In the actual created shortcut I want the section with "$InstDir\DosConfig.conf" to actually have quotes around it in the shortcut file.
What would I use to do this?
I have tried the """ technique and having it actually place a ' around the parameter. Neither of which work.
createShortcut with quotes in the parameter of final shortcut
6 posts
Use $\" to escape quotes.
Or use ` or ' for quoting the argument so no escaping is required.
I.e.
'-conf "$InstDir\DosConfig.conf"'
`-conf "$InstDir\DosConfig.conf"`
Stu
I.e.
'-conf "$InstDir\DosConfig.conf"'
`-conf "$InstDir\DosConfig.conf"`
Stu
It seems the following code just cuts off the part after the -conf parameter. I am guessing that the $\" is actually being taken as a parameter break for CreateShortcut instead of passing it to the final Shortcut parameter.Originally Posted by aerDNA View PostUse $\" to escape quotes.
It is also cutting off the "-" part. I am not sure why on this one.
CreateShortCut $InstDir\Prog.lnk "$PROGRAMFILES\DOS\DOSEmu.exe" "-conf $\"$InstDir\DosConfig.conf$\""
Good idea, but it seems that neither is supported by the receiving program. I had already tested the ' , but missed the `Originally Posted by Afrow UK View PostOr use ` or ' for quoting the argument so no escaping is required.
I.e.
'-conf "$InstDir\DosConfig.conf"'
`-conf "$InstDir\DosConfig.conf"`
Stu
Not quite so sure why, but it appears that creating a Var for it and building the string in a StrCpy worked.Originally Posted by coderwolf View PostIt seems the following code just cuts off the part after the -conf parameter. I am guessing that the $\" is actually being taken as a parameter break for CreateShortcut instead of passing it to the final Shortcut parameter.
It is also cutting off the "-" part. I am not sure why on this one.
StrCpy $ShortcutParameter "-conf $\"$InstDir\DosConfig.conf$\""
CreateShortCut $InstDir\Prog.lnk "$PROGRAMFILES\DOS\DOSEmu.exe" "$ShortcutParameter"
Both escaping and single quotes work for me:
StrCpy $InstDir "c:\path with space\NSIS${NSIS_VERSION}"This gives me:
CreateShortCut "$temp\test1.lnk" "$PROGRAMFILES\DOS\DOSEmu.exe" "-conf $\"$InstDir\DosConfig.conf$\""
CreateShortCut "$temp\test2.lnk" "$PROGRAMFILES\DOS\DOSEmu.exe" '-conf "$InstDir\DosConfig.conf"'
!ifdef NSIS_PACKEDVERSION
!include Win\COM.nsh
!include LogicLib.nsh
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_ShellLink} ${IID_IShellLink} r0 ""
${If} $0 <> 0
${IUnknown::QueryInterface} $0 '("${IID_IPersistFile}",.r1)'
${If} $1 <> 0
${IPersistFile::Load} $1 '("$temp\test2.lnk",0)i.r2'
${IUnknown::Release} $1 ""
${If} $2 = 0
${IShellLink::GetArguments} $0 '(.r1,${NSIS_MAX_STRLEN})i.r2'
DetailPrint "GetArguments: HRESULT=$2 Data=|$1|"
${EndIf}
${EndIf}
${IUnknown::Release} $0 ""
${EndIf}
!endif
GetArguments: HRESULT=0 Data=|-conf "c:\path with space\NSISv3.0.4\DosConfig.conf"|