I have a problem with patching my application. Have installed my application with an installer written in NSIS. Saved the installation path in the registry with
WriteRegStr HKCU "Software\APP" "InstallPath" $InstDir
This works and I can find the key and value in the registry GUI after installation.
In my patch installer I use this function to find the install path:
!include "VPatchLib.nsh"
!include x64.nsh
!include LogicLib.nsh
; Show details
ShowInstDetails show
Function FindInstallPath
ClearErrors
ReadRegStr $0 HKLM Software\APP ""
${If} $0 != ""
MessageBox MB_OK "Install path: $0"
StrCpy $INSTDIR $0
Return
${Else}
MessageBox MB_OK "Path error: '$0'"
Quit
${EndIf}
FunctionEnd
No path is found, and the patch cannot be applied. If I try to read any other key, fx: ReadRegStr $0 HKCU "Software\Realtek\Audio\RtkAudUService\General" "InstallPath"
, the value is returned as expected.
I am on a test user profile, that I created on my own computer. Both my installer and patch trigger the Windows UAC and I type in the admin password.
I really appreciate any help.
Thanks, Andreas
EDIT:
Changed the function, in regard to Anders answer.
Also, this works when im on the admin, but not on a non-admin user.
SetRegView 64
should not be used just because you are running on a 64-bit system. You should only use it if A) You are installing a 64-bit application. B) You need to read/write a Windows-specific registry value.
Usually when you can't find something you wrote it is because you are not using the correct registry view. Try Process Monitor to see which key you are writing to and where you are reading.
You should not really write to HKCU in elevated installers, use HKLM. When a non-admin user UAC elevates they end up with the administrators HKCU and profile!