|
|
#1 |
|
Member
Join Date: May 2003
Posts: 59
|
ReadRegStr - Section choice?
I need to make my installer do 1 of 2 things:
1.: Either do an automated check and set the InstallDir to that or 2.: Have the user choose 1 of 2 install options and it then need to check if the choice is valid. My script is now at the 2.nd choice, but I'd much rather like it if it was the 1.st option my install used. My code is right now like this: DirText \ "If HL / CS directory is not found, please choose the right directory :" InstallDirRegKey HKLM Software\xes InstallDir Function .onInit ReadRegStr $0 HKCU "Software\Valve\Half-Life\" "InstallPath" ;ReadRegStr $0 HKCU "Software\Valve\Counter-Strike" FunctionEnd InstallDir \cstrike SubSection /e "Choose MOD or Retail Counter-strike" Section "Retail" ReadRegStr $INSTDIR HKCU "Software\Valve\Counter-Strike" InstallPath SectionEnd Section "MOD" ReadRegStr $INSTDIR HKCU "Software\Valve\Half-Life" InstallPath SectionEnd SubSectionEnd ..but this really doesn't work, as you might be able to see. Any help would be greatly appriciated. (Sorry for spelling errors) |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
You can check if the read values are correct or not by doing:
code: -Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#3 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
To only allow one component being selected from a group of 2, have a look at Examples\one-section.nsi.
-Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#4 |
|
Member
Join Date: May 2003
Posts: 59
|
So I don't need InstallDir at all, right? Is the code you made a "choose" or "automated" code? It needs to be in a section or function right?
|
|
|
|
|
|
#5 |
|
Member
Join Date: May 2003
Posts: 59
|
So this code would requier the user to choose a directory and it would check the path.. can't it just read the regstr at load or start of installer so the user don't have to do anything other then choose to install it?
|
|
|
|
|
|
#6 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
InstallDir will set the directory on the Directory page, unless it is changed in a function before the user reaches the Directory page.
My code can indeed be used in the .onInit function, then it will set the InstallDir depending on what the registry keys retreaved were. I have made changes so that if both registry values are blank, then it will use the defined InstallDir from compile-time. code: -Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#7 |
|
Member
Join Date: May 2003
Posts: 59
|
Yes now it works! Thank you so very much =D You'v made my day for sure! Thanks again.
Just for the fun of it, what is the difrence of: StrCmp $INSTDIR "" 0 +3 and StrCmp $INSTDIR "" +2 ? What I don't uderstand is the 0. What does it do and why is there no 0 in the 2.nd line? If the InstallDir is Counter-Strike it will not find the path. Only the Half-Life str works :| Last edited by tatsudoshi; 5th August 2003 at 20:10. |
|
|
|
|
|
#8 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
You need to look at the NSIS Documentation on relative and label jumps.
Also look up StrCmp. +3 means jump 3 commands from the current command. 0 means continue from current command to next command. 0 would be the same as using +1. -2 would jump backwards 2 commands. A label is used for the last bit to jump over the Pop $INSTDIR, because relative jumps do not work on Pop, or a number of other commands. Well, looking at the ReadRegStr's you are using HKCU (Current User) and I think you should use HKLM (Local Machine) Also, if you have the Software\Valve\Counter-Strike registry root there, but the value is incorrect (the dir specified does not exist), then it will use the Half-Life value instead (and if that does not exist, then the compile-time InstallDir value will be used instead). -Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#9 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
It's a better idea to use this function just to push the user towards using the right install directory.
So, displaying the directory page no matter what is a good idea... -Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#10 |
|
Member
Join Date: May 2003
Posts: 59
|
Well in my RegDB I have:
HKEY_CURRENT_USER\Software\Valve\_Half-Life "InstallPath" D:\Half-Life and HKEY_CURRENT_USER\Software\Valve\Counter-Strike "InstallPath" D:\Counter-Strike If I rename the HL key to _Half-Life, so only the CS key is valid, the installer does not find it. |
|
|
|
|
|
#11 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
code: Try this, notice I've added messagebox's in which will display the installpath values. -Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#12 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
Does the actual path D:\counter-strike exist on your hard drive?
-Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#13 | |
|
Member
Join Date: May 2003
Posts: 59
|
Quote:
|
|
|
|
|
|
|
#14 |
|
Member
Join Date: May 2003
Posts: 59
|
LoL I made it folder at the Key link and now it works fine.. just shows how much I know ;P
|
|
|
|
|
|
#15 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
Btw, what is in the installer, mod or map?
![]() I used to play Half-Life, CS, DoD before my PC got reformatted. Now I play and make maps for D-Day: Normandy (Quake2) -Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#16 |
|
Member
Join Date: May 2003
Posts: 59
|
It's a cs script ala nextwish but a lot more complex, if I may say so my self
![]() You can tjek out www.x-systems.dk tomorrow to dl it and see what's the fuss is about. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|