|
|
#1 |
|
Registered User
Join Date: Dec 2006
Posts: 14
|
Install using Registry Key
I have searched and tried every thing I can think of and have read, but I cannot seem to get this to work.
I have a registry key at HKLM "SOFTWARE\MyProgram" "" Basically it shows the location of the install. I have a patched file that needs to go into the location the key shows, but in a sub folder so if the key shows C:\Program Files\MyProgram, I need it in C:\Program Files\MyProgram\lib I have tried this but it just wont work Section "MainSection" SEC01 ReadRegStr $0 HKLM SOFTWARE\MyProgram "" IfFileExists $0\lib +2 StrCpy $0 "$INSTDIR" SetOutPath $0 SetOverwrite on File "file.txt" SectionEnd I also tried to add the lib part on the SetOutPath, no worky |
|
|
|
|
|
#2 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Assuming that the mentioned key behaves like the InstallDirRegKey and shows the installation dir, all you need is:
ReadRegStr $0 HKLM "SOFTWARE\MyProgram" "" SetOutPath "$0\lib" or in function .onInit ReadRegStr $0 HKLM "SOFTWARE\MyProgram" "" StrCpy $INSTDIR "$0\lib" Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jan 2008
Posts: 9
|
Well, I searched for the term registry folder and read 10 pages worth of stuff and tried all of them. Using the onit, getParent, read the key, etc. For some reason it just wont pick it up. I have used the install directory registry key string and it will read fine from the key. However, when I try to use a read reg key in the section it isn't working.
I tried what you had Red, but it didn't work either...I am posting my code... Also, for some reason my other account went dead? Not sure what happened to it. |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jan 2008
Posts: 9
|
Forgot the file
|
|
|
|
|
|
#5 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
InstallDirRegKey has some minor processing applied to the registry key specified. For example, if it detects a path to an executable, it removes the last part. Make sure $0 contains exactly what you think it contains.
You should use $SYSDIR instead of C:\Windows\System32. NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jan 2008
Posts: 9
|
When it reads the registry key it pulls
C:\Program Files\MyProgram If I use InstallDirRegKey in a non section it correctly pulls the directory...however what I need to do is append what it pulled and add \lib...so I tried various ways in the Section to read the key and add the \lib..tried Reds way and it didn't work for some reason...it might be something in my script that is why I posted it....I'm lost, it's like it totally ignores the setoutputpath in the Section |
|
|
|
|
|
#7 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
According to the code that you've posted above, you're attempting to read a registry key which obviously doesn't exist, so $0 should be empty and the error flag up.
The key doesn't exist because your script missing that part where it should create it upon successful installation. Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jan 2008
Posts: 9
|
Something isn't right...the key is there because I can see it in the registry and it is at HKLM Software\MyProgram There are two strings in there...one is a default string and another is a DB location. If I take out the ReadRegStr part in the Section and use InstallDirRegKey HKLM "SOFTWARE\${SHORTNAME}" "" it correctly sets the install location. So that is where I am confused...I take the InstallDirRegKey out and use ReadRegStr in the Section and it doesn't work....
|
|
|
|
|
|
#9 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Check the value of $0 after you read it from the registry using a message box.
Stu |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jan 2008
Posts: 9
|
Ok...I see what is going on, but I haven't figured out how to fix it. I just took that page off since it is a patch anyway..it IS going to the right directory, however when it goes to this page
; Directory page !insertmacro MUI_PAGE_DIRECTORY it is printing out the wrong directory not the one that is read in the section...like I said I don't need it because it is a patch and the registry key correctly points to the location I need it to. |
|
|
|
|
|
#11 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
You need to use !define MUI_DIRECTORYPAGE_VARIABLE $Var
Otherwise it will use $INSTDIR. Stu |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|