Accessing command line arguments in NSIS
Asked Answered
M

2

11

I am trying to make my setups scripts modular. I am calling setup exe's from within main setup script based to the requirements. I want to pass command line arguments to the exe being called. Can someone please tell me how to access the command line arguments in the script being called.

Thanks in advance.

Mcgrody answered 31/5, 2011 at 10:6 Comment(0)
D
23

you can use GetOptions function (FileFunc.nsh must be included above). Following example shows p parameter reading; its value is saved into the variable. $CMDLINE is your command line (absolute or relative, as you called) containing also your parameters.

!include FileFunc.nsh

Var variable    
${GetOptions} $CMDLINE "/p" $variable
Democratize answered 31/5, 2011 at 10:40 Comment(2)
Just to define ' Var variable' before the call.Ulises
Use GetParameters instead of $CMDLINE, as the latter contains the exe name which can get in the way. See example here.Hardman
I
1

Try to get options from Command line by their name: http://nsis.sourceforge.net/Get_command_line_parameter_by_name

Impedimenta answered 1/6, 2011 at 14:10 Comment(1)
Didn't work for me, was happy to find the accepted answer.Oceanid

© 2022 - 2024 — McMap. All rights reserved.