Skip to content
⌘ NSIS Forum Archive

GetParameters and /D=

6 posts

stopasking#

GetParameters and /D=

Hello,

I need to know whether the user chose a custom directory using the command line parameter.
I wanted to use GetParameters, only to know it doesn't return the /D= parameter.
Any alternatives?
MSG#
I'll hazard a guess:

Function .onInit
${If} $INSTDIR != "YourDefaultDirectory"
MessageBox MB_OK "Custom folder."
${EndIf}
FunctionEnd
Anders#
What Msg suggests will probably work 99% of the time (The last percent is for short names and junctions etc)

...but why do you care?
Yathosho#
Originally Posted by stopasking View Post
I wanted to use GetParameters, only to know it doesn't return the /D= parameter.
GetOptions is used for that
Afrow UK#
Instead you can just omit InstallDir and therefore $INSTDIR will be empty in .onInit unless /D= was passed (with a value). If $INSTDIR is empty, just set a $INSTDIR value with StrCpy.

@Yathosho: /D= isn't included in $CMDLINE (manual states this).

Stu