Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   GetParameters Usage in NSIS (http://forums.winamp.com/showthread.php?t=274505)

ramyaa 17th July 2007 13:37

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

theblazingangel 17th July 2007 13:58

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

how i do it:

1) includes:
code:
!insertmacro GetParameters
!insertmacro GetOptions



2) oninit:
code:
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:
code:
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


ramyaa 18th July 2007 08:33

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

theblazingangel 18th July 2007 15:20

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.

damdare 5th March 2009 12:05

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

uahmed 21st June 2011 06:50

Hi

Can it be possible to give argument to nsi script ?

I want to make the script Generalize .

MSG 21st June 2011 06:56

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


All times are GMT. The time now is 17:19.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.