Archive: GetParameters Usage in NSIS


GetParameters Usage in NSIS
Hi,

Anybody aware of the usage of GetParameters function in NSIS?? Which command line parameter does this function fetch?? I mean, where should the command line parameter be given??
If anybody knows, plz reply...

Thanks,
Ramya


it gets all parameters, you can then use GetOptions to check for specific parameters.

how i do it:

1) includes:

!insertmacro GetParameters
!insertmacro GetOptions


2) oninit:
Function .onInit

; Get parameters

var /GLOBAL cmdLineParams
Push $R0

${GetParameters} $cmdLineParams

; /? param (help)
ClearErrors
${GetOptions} $cmdLineParams '/?' $R0
IfErrors +3 0
MessageBox MB_OK "list all command line options here!"
Abort

Pop $R0

; Initialise options

Var /GLOBAL option_runProgram
Var /GLOBAL option_startMenu
Var /GLOBAL option_startMenuAllUsers
Var /GLOBAL option_shortcut
Var /GLOBAL option_shortcutAllUsers

StrCpy $option_runProgram 1
StrCpy $option_startMenu 1
StrCpy $option_startMenuAllUsers 0
StrCpy $option_shortcut 1
StrCpy $option_shortcutAllUsers 0

; Parse Parameters

Push $R0
Call parseParameters
Pop $R0

FunctionEnd


3) parseParameters function:
Function parseParameters

; /norun
${GetOptions} $cmdLineParams '/norun' $R0
IfErrors +2 0
StrCpy $option_runProgram 0

; /nostartmenu
${GetOptions} $cmdLineParams '/nostartmenu' $R0
IfErrors +2 0
StrCpy $option_startMenu 0

; /starmenuallusers
${GetOptions} $cmdLineParams '/startmenuallusers' $R0
IfErrors +2 0
StrCpy $option_startMenuAllUsers 1

; /noshortcut
${GetOptions} $cmdLineParams '/noshortcut' $R0
IfErrors +2 0
StrCpy $option_shortcut 0

; /shortcutallusers
${GetOptions} $cmdLineParams '/shortcutallusers' $R0
IfErrors +2 0
StrCpy $option_shortcutAllUsers 1

FunctionEnd

Thanks theblazingangel for the reply. Could you please tell me where we give the command line parameters for a .nsi file? Is it like
abc.nsi /norun

Also is it possible to give command-line parameters like in any other files.... like

xyz.c "1" "abcd"
Here "1" and "abcd" are cmd-line parameters. Is a similar thing possible in abc.nsi file??

Thanks,
Ramya


no no no, you don't pass the command line parameters to a .nsi file, you compile the .nsi file into a .exe and then you can pass the parameters to the .exe you've made.


theblazingangel, this is possibly the best written post I've ever seen. Clear and effective.
Thank you


Hi

Can it be possible to give argument to nsi script ?

I want to make the script Generalize .


uahmed: You already asked this question in your own thread. In fact, I already *replied* there. Please don't ask the same question twice.

http://forums.winamp.com/showthread.php?t=331740