Old 17th July 2007, 13:37   #1
ramyaa
Junior Member
 
Join Date: Jul 2007
Posts: 8
Unhappy 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
ramyaa is offline   Reply With Quote
Old 17th July 2007, 13:58   #2
theblazingangel
Junior Member
 
Join Date: Mar 2006
Posts: 29
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

theblazingangel is offline   Reply With Quote
Old 18th July 2007, 08:33   #3
ramyaa
Junior Member
 
Join Date: Jul 2007
Posts: 8
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
ramyaa is offline   Reply With Quote
Old 18th July 2007, 15:20   #4
theblazingangel
Junior Member
 
Join Date: Mar 2006
Posts: 29
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 is offline   Reply With Quote
Old 5th March 2009, 12:05   #5
damdare
Junior Member
 
Join Date: Mar 2009
Posts: 1
theblazingangel, this is possibly the best written post I've ever seen. Clear and effective.
Thank you
damdare is offline   Reply With Quote
Old 21st June 2011, 06:50   #6
uahmed
Junior Member
 
Join Date: Jun 2011
Posts: 2
Hi

Can it be possible to give argument to nsi script ?

I want to make the script Generalize .
uahmed is offline   Reply With Quote
Old 21st June 2011, 06:56   #7
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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
MSG 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