Archive: Launch Parameters into variables


Launch Parameters into variables
  Is it possible to set parameters at the start of the installer so that they appear in variable form?

example
nsis_install.exe /var=5
the above sets ${VAR} to 5

or something similar.

Thanks.


${VAR} isn't a variable, it's a define.

What you probably want to do is get the parameter in .onInit (google is your friend), then StrCpy $VAR ParamValue .


You can use the Files functions header (Appendix E.1 of the manual)

I personally use something like this:


"FileFunc.nsh"

>!insertmacro GetParameters
>!insertmacro GetOptions

>${GetParameters} $R0
>${GetOptions} $R0 "-p" $R1
IfErrors NoCmdLineOptionSet

; ... do whatever you need with the value in $R1

NoCmdLineOptionSet:
>MessageBox MB_ICONEXCLAMATION|MB_OK 'No Option set'
>Abort $R2
>
${GetParameters} will get you the command line options passed to the installer executable and ${GetOptions} can get you the contents of a option passed and/or if it was present or not.

After you get the parameter, you can set it to a variable with a StrCpy as MSG posted.

As I said before, the documentation is in the Appendix E (Useful Headers) in the File Functions Header section.