Archive: Secondary Installation Directory


Secondary Installation Directory
Hi...I was wandering if it was possible to make a sort of secondary installation directory? (Note: I'm a complete n00b at NSIS.) I'm wanting something like...

InstallDirRegKey HKLM "SOFTWARE\Microsoft\MSNMessenger" "InstallationDirectory"
InstallDir2RegKey HKLM "SOFTWARE\Patchou\MsgPlus2" "InstallationDirectory2"

Now I know that won't work like that...but is there any way to do it? Even if I had to download some sort of plugin, I'd be happy to do so.


You can read this key inside .onInit function and store it in user variable.
Var InstDir2
...
ReadRegStr $InstDir2 $HKLM "SOFTWARE\Patchou\MsgPlus2" "InstallationDirectory2"


Errors...
Thanks for the quick reply...unfortunately it's giving me errors :( (As I said...I'm a complete n00b so it's entirely possible I've made an obvious mistake). I'm attaching my script so you can see if I've done it right...just tell me if I've been a complete idiot. :)


Re: Errors...

Originally posted by Jaymach
Thanks for the quick reply...
:) Very quick - 1 hour. :D
Add before section instfiles
Var InstDir2
.
And my typo
ReadRegStr $InstDir2 HKLM "SOFTWARE\Patchou\MsgPlus2" "InstallationDirectory2"
Try this. Post if will other errors.

Lol...it was quick by my standards seeing as I usually wait about a day to get help. :P When I add it before instfiles I get

Error: command ReadRegStr not valid outside section or function


Leave ReadRegStr in section. Add this line before section

Var InstDir2

Sorry about not replying sooner. :) Working perfectly apart from me calling the wrong part of the registry lol...thanks once more for the help. :)


Did you end up putting it in a section?
If so, then you should put it in your second directory page's Pre function:

Var INSTDIR2
!define MUI_PAGE_CUSTOMFUNCTION_PRE getInstDir
!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR2
!insertmacro MUI_PAGE_DIRECTORY

Now put that code in a Function named getInstDir.
This will put the value of $INSTDIR2 into your Directory path box.

-Stu


Well I...uh...have no idea how to do that. :)...but a new problem...is there any way for me to get the installer to look for 2 entries in the Registry? I need it to look in both HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\MsgPlus2 and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Patchou\MsgPlus2 as on my Windows XP x64 edition, the 1st location isn't there, and has been moved to the 2nd location. I'm trying to make my installer run on both versions, so is there any way for me to try to detect both?


Easier than you think.

Var INSTDIR2
!define MUI_PAGE_CUSTOMFUNCTION_PRE getInstDir
!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR2
!insertmacro MUI_PAGE_DIRECTORY

Function getInstDir
ReadRegStr $INSTDIR2 HKLM "SOFTWARE\Patchou\MsgPlus2" "keyname"
StrCmp $INSTDIR2 "" 0 +2
ReadRegStr $INSTDIR2 HKLM "SOFTWARE\Wow6432Node\Patchou\MsgPlus2" "keyname"
StrCmp $INSTDIR2 "" 0 +2
StrCpy $INSTDIR2 "C:\default install dir"
FunctionEnd


-Stu