Old 28th October 2008, 17:08   #1
Richard_P
Junior Member
 
Join Date: Oct 2008
Posts: 2
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
Richard_P is offline   Reply With Quote
Old 28th October 2008, 19:06   #2
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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:
code:
!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

Comperio is offline   Reply With Quote
Old 29th October 2008, 08:41   #3
Richard_P
Junior Member
 
Join Date: Oct 2008
Posts: 2
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).
code:

!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

Richard_P is offline   Reply With Quote
Old 29th October 2008, 17:44   #4
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Quote:
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!
Comperio 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