Skip to content
⌘ NSIS Forum Archive

$INSTDIR with spaces causes problems as a parameter

6 posts

Guest#

$INSTDIR with spaces causes problems as a parameter

Hi,

I am trying to run a program at the end of an instalation, for example

!define MUI_FINISHPAGE_RUN "$INSTDIR\MyProgram.exe"

and pass it the instalation directory as a parameter

!define MUI_FINISHPAGE_RUN_PARAMETERS "$INSTDIR"

However when MyProgram.exe runs it only gets C:\Program instead of the entire path.

Now, I figure, okay I need to add quotes around $INSTDIR, so I change it to this...

!define MUI_FINISHPAGE_RUN_PARAMETERS '"$INSTDIR"'

but now MyProgram.exe does not even get executed at the end of installation.

What is the solution to this? I can't see any other way around it. I don't wanna have to go back to using msi 🙁

Mark
pengyou#
When I tried a simple example it worked OK, and the program started by the installer found the correct value for $INSTDIR even if it contained spaces.

Perhaps the problem is that the program you are running stops reading the command-line parameter when it finds a space, so you need to enclose the parameter in quotes?

If you use

!define MUI_FINISHPAGE_RUN_PARAMETERS $\"$INSTDIR$\"

and use C:\Program Files\My Demo for the installation then your program should find the command-line contains

"C:\Program Files\My Demo"

instead of just

C:\Program Files\My Demo
Guest#
hmm i am using HM NISEdit as my environment around nsis. Is this known to have this type of issue?

I will try escaping the quotes as per your example. Thanks.
Brummelchen#
In worst case use GetShortName (nsis function) and have a 8 character limit 😉

>> C:\Program Files\My Demo

becomes

C:\Progra~1\MyDemo~1

8.3 is recommended while using Exec with dosbox programs (like RAR.EXE or 7ZA.EXE)
Brummelchen#
Sorry, must be "GetFullPathName /SHORT user_var(output) path_or_file"

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.