Archive: Control script with arguments


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


have a look at the /D switch for makensis

http://nsis.sourceforge.net/Docs/Chapter3.html#3.1.1


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


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.


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


I found it!

!ifdef


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

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?