NikMonkey_25
29th March 2007 12:05 UTC
How To: Installer with choice of shortcut command line parameters?
Hi,
I am trying to create an installer which creates a desktop and start menu shortcut with command line parameters.
The application being installed has two operating modes: real-time, and viewing only. Both modes require different command line parameters.
I want the installer to give the user the option to select which mode to be installed, and add the correct command line parameters to the shortcuts accordingly.
What's the best way of doing this?
Cheers
Nik
onad
29th March 2007 12:31 UTC
Use the GetOptions macro, search Wiki for this, also added below so you can get started just in case.
Then as example here add to your "function .onInit"
${GetOptions} $CMDLINE "/L" $R0
IfErrors SkipLogSet 0
MessageBox MB_ICONQUESTION|MB_OK "Logset found and additional value is >$R0"
LogSet on
SkipLogSet:
==================================
Function GetOptions
!define GetOptions `!insertmacro GetOptionsCall`
!macro GetOptionsCall _PARAMETERS _OPTION _RESULT
Push `${_PARAMETERS}`
Push `${_OPTION}`
Call GetOptions
Pop ${_RESULT}
!macroend
Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7
ClearErrors
StrCpy $2 $1 '' 1
StrCpy $1 $1 1
StrLen $3 $2
StrCpy $7 0
begin:
StrCpy $4 -1
StrCpy $6 ''
quote:
IntOp $4 $4 + 1
StrCpy $5 $0 1 $4
StrCmp $5$7 '0' notfound
StrCmp $5 '' trimright
StrCmp $5 '"' 0 +7
StrCmp $6 '' 0 +3
StrCpy $6 '"'
goto quote
StrCmp $6 '"' 0 +3
StrCpy $6 ''
goto quote
StrCmp $5 `'` 0 +7
StrCmp $6 `` 0 +3
StrCpy $6 `'`
goto quote
StrCmp $6 `'` 0 +3
StrCpy $6 ``
goto quote
StrCmp $5 '`' 0 +7
StrCmp $6 '' 0 +3
StrCpy $6 '`'
goto quote
StrCmp $6 '`' 0 +3
StrCpy $6 ''
goto quote
StrCmp $6 '"' quote
StrCmp $6 `'` quote
StrCmp $6 '`' quote
StrCmp $5 $1 0 quote
StrCmp $7 0 trimleft trimright
trimleft:
IntOp $4 $4 + 1
StrCpy $5 $0 $3 $4
StrCmp $5 '' notfound
StrCmp $5 $2 0 quote
IntOp $4 $4 + $3
StrCpy $0 $0 '' $4
StrCpy $4 $0 1
StrCmp $4 ' ' 0 +3
StrCpy $0 $0 '' 1
goto -3
StrCpy $7 1
goto begin
trimright:
StrCpy $0 $0 $4
StrCpy $4 $0 1 -1
StrCmp $4 ' ' 0 +3
StrCpy $0 $0 -1
goto -3
StrCpy $3 $0 1
StrCpy $4 $0 1 -1
StrCmp $3 $4 0 end
StrCmp $3 '"' +3
StrCmp $3 `'` +2
StrCmp $3 '`' 0 end
StrCpy $0 $0 -1 1
goto end
notfound:
SetErrors
StrCpy $0 ''
end:
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
NikMonkey_25
29th March 2007 13:02 UTC
Cheers onad, but that's not exactly what I am trying to do. I don't want to get options from the command line.
I need to display a page with two install options (e.g. radio buttons) one for real-time and one for viewing only.
If the user selected real time option button, the files would be installed and a desktop shortcut created with specific parameters i.e.:
CreateShortcut $DESKTOP\BGSTATS_5g.lnk "$INSTDIR\BGSTATS_5g.exe" "\\prview1\prview1_c\ddstats\live\real-time /a"
And if the user selected viewing only install, the desktop shortcut would be:
CreateShortcut $DESKTOP\BGSTATS_5g.lnk "$INSTDIR\BGSTATS_5g.exe" "\\prview1\prview1_c\ddstats\live\real-time"
Cheers
Afrow UK
29th March 2007 18:04 UTC
Use InstallOptions. For an installer I did not too long ago, I used the InstallOptions INI file that NSIS uses for the uninstall and do not uninstall options. You'll find it under NSIS\Examples\makensis.ini
Stu