View Single Post
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