- NSIS Discussion
- Secondary Installation Directory
Archive: Secondary Installation Directory
Jaymach
1st July 2005 11:23 UTC
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.
glory_man
1st July 2005 12:40 UTC
You can read this key inside .onInit function and store it in user variable.
Var InstDir2
...
ReadRegStr $InstDir2 $HKLM "SOFTWARE\Patchou\MsgPlus2" "InstallationDirectory2"
Jaymach
1st July 2005 13:22 UTC
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. :)
glory_man
1st July 2005 13:47 UTC
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.
Jaymach
1st July 2005 13:50 UTC
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
glory_man
1st July 2005 13:54 UTC
Leave ReadRegStr in section. Add this line before section
Var InstDir2
Jaymach
1st July 2005 14:38 UTC
Sorry about not replying sooner. :) Working perfectly apart from me calling the wrong part of the registry lol...thanks once more for the help. :)
Afrow UK
1st July 2005 20:34 UTC
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
Jaymach
2nd July 2005 08:40 UTC
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?
Afrow UK
2nd July 2005 12:35 UTC
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