Archive: MultiUser support and InstallDir


MultiUser support and InstallDir
Hello,

I have 2 issues with using MultiUser.nsh and setting installation directory:

1. Command line parameter /D is ignored when using macro MULTIUSER_INIT. Path from parameter /D is overriden by MULTIUSER_INSTALLMODE_INSTDIR_x defines for setting INSTDIR. I need parameter /D to have highest priority.

2. When string from registry is found by defines MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_x, MultiUser support sets INSTDIR including file name. This is different behavior from InstallDirRegKey, that removes file name.

It's simple to workaround the second issue, but don't know how to solve the first one.

Thanks for any help


I haven't played with MultiUser (haven't really had a need). But, if I'm reading the documnetation correctly, the install directory is set by defining MULTIUSER_INSTALLMODE_INSTDIR before using !insertmacro MULTIUSER_INIT. (Hopefully, that's right.)

If so, here's something you might try:

!include LogicLib.nsh
!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions
var MyInstDir
...

Function .onInit
${GetParameters} $0
${GetOptions} "$0" "\D" $1
${If} "$1" == ""
; no command line, so set default dir here:
StrCpy $MyInstDir "C:\default_Directory"
${Else}
StrCpy $MyInstDir "$1"
${EndIf}
!define MULTIUSER_INSTALLMODE_INSTDIR "$MyInstDir"
!insertmacro MULTIUSER_INIT
FunctionEnd

Thanks, I got it. I used custom parameter /INSTDIR instead of native /D, that can't be extracted by GetParameters (see documentation for Variables, $CMDLINE).


!define MULTIUSER_INSTALLMODE_INSTDIR "MyAppDefaultDir"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "MyAppRegKey"
!include "MultiUser.nsh"

!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions
Var cmdLineInstallDir

Function .onInit
${GetParameters} $0
ClearErrors
${GetOptions} '$0' "/INSTDIR=" $1
IfErrors +2
StrCpy $cmdLineInstallDir $1
ClearErrors

!insertmacro MULTIUSER_INIT

StrCmp $cmdLineInstallDir "" +2
StrCpy $INSTDIR $cmdLineInstallDir
FunctionEnd

Originally posted by Richard_P
Thanks, I got it. I used custom parameter /INSTDIR instead of native /D, that can't be extracted by GetParameters (see documentation for Variables, $CMDLINE).
Good catch! (Goes to show I don't mess with that too often, huh? ;) )

I'm glad you got it to work!