fluidz91
21st March 2008 16:28 UTC
Problem with InstallDirRegKey
Hello,
I found in NSIS\Examples\bigtest.nsi an example that uses InstallDirRegKey
InstallDirRegKey HKLM "Software\NSISTest\BigNSISTest" ""
When i test the script $INSTDIR is not set properly. I changed the script to
InstallDirRegKey HKLM "Software\NSISTest\BigNSISTest" "Install_Dir"
And now $INSTDIR is set to the correct path read on the registry.
I tried to put InstallDirRegKey in my own script but $INSTDIR is always set to
InstallDir.
I found a workaround in NSIS Manual that consists of
Function .onInit
...
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
StrCmp $INSTDIR "" label1 label2
...
FunctionEnd
But i was wondering why i was not able to make InstallDirRegKey work...
If anyone has an idea what i could do wrong.
i used EclipseNSIS wizard to make my script with MUI interface
...
!define REGKEY "SOFTWARE\${COMPANY}\$(^Name)"
...
InstallDir "$PROGRAMFILES\$(^Name)\"
InstallDirRegKey HKLM "${REGKEY}" "Path"
...
I also used dumpstate::debug to set breakpoint to see what was the value of $INSTDIR and found it was set to InstallDir but was unable to debug InstallDirRegKey.
kichik
21st March 2008 17:26 UTC
Example fixed.
As for your code, do you have a WriteRegStr there as well?
fluidz91
21st March 2008 17:40 UTC
Hi kichik !
Extract of my nsi script :
Section -post SEC0002
...
WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
...
SectionEnd
kichik
21st March 2008 17:41 UTC
Have you verified it's written there?
fluidz91
21st March 2008 17:56 UTC
For me it is written in the registry at the right place.
I guess if it wasn't, the code below i use as a workaround wouldn't work, would it ? :
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
More information :
"${REGKEY}" contains spaces
Tried entry_name with and without quotes
makensis version 2.17
{_trueparuex^}
21st March 2008 19:00 UTC
The language string $(^Name) doesn't work in InstallDirRegKey because lang strings aren't initialized at the point InstallDirRegKey is called.
So instead of geting the InstallDir from key Software\NSISTest\BigNSISTest it's trying to get it from key Software\NSISTest\$(^Name)
If you want to use $(^Name) in the key. Use ReadRegStr $INSTDIR HKLM "${REGKEY}" after .onInit is called.
fluidz91
25th March 2008 10:48 UTC
Thank you very much {_trueparuex^} ! i have now my explanation why i couldn't use InstallDirRegKey.
I already used ReadRegStr .onInit as a workaround...
Thx All again !
fluidz91
26th March 2008 16:59 UTC
i just realized that it means that the Wizard of EclipseNSIS has a bug because it adds the lines :
...
!define REGKEY "SOFTWARE\$(^Name)"
...
InstallDirRegKey HKLM "${REGKEY}" Path
Is it posible to access constant/variable "Name" otherwise by $(^Name) ? I tried ${Name} but didn't work.