Ema
14th February 2008 17:00 UTC
Control script with arguments
Hi all,
Don't know if this is feasible,
I'd like to change the setup executable generation acording to some input variable.
Let's say when launching the setup generation
makensis.exe myscript.nsi myPar
if myPar is equal to ADD_WELCOME
I would like to generate the setup adding the following line:
!define MUI_FINISHPAGE_SHOWREADME "http://www.test.com"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Welcome"
Hope I wasn't too confusing.
Thanks for any help
Yathosho
14th February 2008 17:05 UTC
have a look at the /D switch for makensis
http://nsis.sourceforge.net/Docs/Chapter3.html#3.1.1
Ema
14th February 2008 17:16 UTC
Thanks for answering
From the docs it's no t clear to me how to use it, it seems it's used only to set the $INSTDIR.
installer.exe /D=C:\Program Files\NSIS
And then I don't know if I can use to comment/uncomment lines in NSIS
something like
if !isdefined(Myvar)
{
!define MUI_FINISHPAGE_SHOWREADME "http://www.test.com"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Welcome"
}
Thanks again
kichik
14th February 2008 17:21 UTC
You're looking at the wrong "/D". Yathosho was referring to section 3.1 and not section 3.2. The first section describes command line arguments passed to the compiler while the second describes those passed to the installer itself.
Ema
14th February 2008 17:30 UTC
sorry, next time I'll read more carefully
still I don't know how to then use this inside the script to select or unselect lines of code, like the welcome page.
thanks
Ema
14th February 2008 17:34 UTC
I found it!
!ifdef
kichik
14th February 2008 17:34 UTC
It defines constants in the script. If you execute:
makensis /DMYVAR myscript.nsi
you'll have MYVAR defined in the context of your script and you could then use:
!ifdef MYVAR
# something
!endif
jozechu
21st April 2008 16:51 UTC
I was also confused between compiler defines and installer defines.
But, I've tried a lot of combinations to define a variable from command line but it never make my script works ...
myinstaller /DMYVAR=bla
!ifdef MYVAR
!define BASE_DIR "${MYVAR}"
!else
!define BASE_DIR "C:\default"
!endif
I'm missing something?