Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 3rd March 2015, 20:39   #1
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
createShortcut with quotes in the parameter of final shortcut

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.
coderwolf is offline   Reply With Quote
Old 3rd March 2015, 21:30   #2
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
Use $\" to escape quotes.

PostEnd:
aerDNA is offline   Reply With Quote
Old 4th March 2015, 06:47   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Or use ` or ' for quoting the argument so no escaping is required.

I.e.
'-conf "$InstDir\DosConfig.conf"'
`-conf "$InstDir\DosConfig.conf"`

Stu
Afrow UK is offline   Reply With Quote
Old 4th March 2015, 13:43   #4
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
Quote:
Originally Posted by aerDNA View Post
Use $\" to escape quotes.
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.
It is also cutting off the "-" part. I am not sure why on this one.
Quote:
CreateShortCut $InstDir\Prog.lnk "$PROGRAMFILES\DOS\DOSEmu.exe" "-conf $\"$InstDir\DosConfig.conf$\""
Quote:
Originally Posted by Afrow UK View Post
Or use ` or ' for quoting the argument so no escaping is required.

I.e.
'-conf "$InstDir\DosConfig.conf"'
`-conf "$InstDir\DosConfig.conf"`

Stu
Good idea, but it seems that neither is supported by the receiving program. I had already tested the ' , but missed the `
coderwolf is offline   Reply With Quote
Old 4th March 2015, 13:57   #5
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
Quote:
Originally Posted by coderwolf View Post
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.
It is also cutting off the "-" part. I am not sure why on this one.
Not quite so sure why, but it appears that creating a Var for it and building the string in a StrCpy worked.

Quote:
StrCpy $ShortcutParameter "-conf $\"$InstDir\DosConfig.conf$\""
CreateShortCut $InstDir\Prog.lnk "$PROGRAMFILES\DOS\DOSEmu.exe" "$ShortcutParameter"
coderwolf is offline   Reply With Quote
Old 4th March 2015, 13:59   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,522
Both escaping and single quotes work for me:
Quote:
StrCpy $InstDir "c:\path with space\NSIS${NSIS_VERSION}"
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
This gives me:
Quote:
GetArguments: HRESULT=0 Data=|-conf "c:\path with space\NSISv3.0.4\DosConfig.conf"|

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump