Archive: passing parameters to the installers .exe


passing parameters to the installers .exe
Hi

I want to pass parameters to the installers executable, for example:


# define name of installer
outFile "installer.exe"

# define installation directory
installDir $DESKTOP

# start default section
section

# set the installation directory as the destination for the following actions
setOutPath $INSTDIR

# create the uninstaller
writeUninstaller "$INSTDIR\uninstall.exe"

# create a shortcut named "new shortcut" in the start menu programs directory
# point the new shortcut at the program uninstaller
createShortCut "$SMPROGRAMS\new shortcut.lnk" "$INSTDIR\uninstall.exe"
sectionEnd

Function .onInit
Call GetParameters
Pop $0
Pop $1
MessageBox MB_OK "$0 $1"
WriteRegStr HKLM "Software\JavaSoft\Prefs\MyApp" "$0" "$1"
FunctionEnd

Function GetParameters

Push $R0
Push $R1
Push $R2
Push $R3

StrCpy $R2 1
StrLen $R3 $CMDLINE

;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "

loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop

get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2

Pop $R3
Pop $R2
Pop $R1
Exch $R0

FunctionEnd

# uninstaller section start
section "uninstall"

# first, delete the uninstaller
delete "$INSTDIR\uninstall.exe"

# second, remove the link from the start menu
delete "$SMPROGRAMS\new shortcut.lnk"

# uninstaller section end
sectionEnd


I pass in 2 parameters and both parameters are then popped out into registers $0 & $1 which I then display. The problem is when I write to the registry it displays both $0 & $1 in the same 'key' and there is no 'value'.

If I was to hard code it say:


WriteRegStr HKLM "Software\JavaSoft\Prefs\zangbezang" "Key" "Value"


It works ok. Obviously I am doing something wrong with strings and registry values.

Any ideas?

Cheers

GetParameters returns all of the parameters in one string. Use the following to get a specific command line parameter:

http://nsis.sourceforge.net/GetONEPa...ine_parameters

Or split what you already have with WordFind.


Or use GetParameters followed by GetOptions, both of which are in FileFunc.nsh

Stu


Thanks guys.