Old 22nd February 2010, 08:40   #1
nroach
Junior Member
 
Join Date: Feb 2010
Posts: 1
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.
nroach is offline   Reply With Quote
Old 22nd February 2010, 09:19   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
${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 .
MSG is offline   Reply With Quote
Old 22nd February 2010, 11:11   #3
rsvargas
Junior Member
 
Join Date: Apr 2008
Location: Florianópolis, SC - Brazil
Posts: 16
Send a message via ICQ to rsvargas
You can use the Files functions header (Appendix E.1 of the manual)

I personally use something like this:

PHP Code:
!include "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.
rsvargas is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump