Reputation: 724
I'm making a simple NSIS installator on Win 10 and I'm having some issues with a function ReadRegStr
. ReadRegStr
returns an empty string and sets a error flag which means the value could not be found. The value definitely exists (it was made by me) and is of a proper type REG_SZ.
The same behavior occurs even with SOME other keys:
Powershell finds the values without any problems.
PS C:\Users\Admin\test> Get-ItemProperty -Path HKLM:\SOFTWARE\FooBar
(default) : fb
Here is a lightweight nsi
script which I'm using
OutFile "Installer.exe"
Var FOO_VAR
!include LogicLib.nsh
Section
ReadRegStr $FOO_VAR HKLM "SOFTWARE\FooBar" ""
${If} ${Errors}
MessageBox MB_OK "Value not found"
${Else}
MessageBox MB_OK "FooBar $FOO_VAR"
${EndIf}
SectionEnd
All the keys above have at least read permission for every user/installer. What else could be causing this?
Upvotes: 1
Views: 4816
Reputation: 101626
64-bit Windows has two registry "views" and 32-bit applications see the 32-bit view by default. You can use the SetRegView
instruction to force a 32-bit NSIS installer to use to the 64-bit view:
!include x64.nsh
!include LogicLib.nsh
Section
${If} ${RunningX64}
SetRegView 64
ReadRegStr ... value on 64-bit systems
SetRegView LastUsed
${Else}
ReadRegStr ... value on 32-bit systems
${EndIf}
SectionEnd
Upvotes: 4