Using InstallDirRegKey twice
Hi all,
I have searched the board but can't find an answer, so here goes....
I need to read a reg key to set the $INSTDIR variable, then compare it with the default $INSTDIR variable which I am setting earlier. If they are the same, then I know that the reg key does not exist (or the value could be the same), so I have to read another reg key for the install path. I am doing this because previous versions of the software put the InstallDir key in the HKCU but current versions put it in HKLM. So, I have to check HKCU first. If a value is read from that key, then I don't need to check the HKLM.
Here's my script:
; set the default
InstallDir "$PROGRAMFILES\${MUI_APPNAME}"
; read from my HKCU reg key
InstallDirRegKey HKCU "SOFTWARE\${MUI_APPNAME}" "InstallDir"
; compare the reg key to my default
; if they are the same, the reg key doesn't exist...
StrCmp $INSTDIR "$PROGRAMFILES\${MUI_APPNAME}" 0
; ... so read the reg key from the HKLM root
InstallDirRegKey HKLM "SOFTWARE\${MUI_APPNAME}" "InstallDir"
But, I get compilation errors because StrCmp must be in a Section or Function. But if I put all of that in a section or function, I get compilation errors because the InstallDir... commands can't be in sections or functions!
The following doesn't work either:
InstallDir "$PROGRAMFILES\${MUI_APPNAME}"
InstallDirRegKey HKCU "SOFTWARE\${MUI_APPNAME}" "InstallDir"
InstallDirRegKey HKLM "SOFTWARE\${MUI_APPNAME}" "InstallDir"
If the HKLM key doesn't exist, it always uses the default $INSTDIR, so it's as if the HKCU key value doesn't matter.
Is there a way to do this?
Thanks,
Bob