Search code examples
windows-7nsis

NSIS: Unable to write to registry (HKLM\Software\...) on Windows 7


I'm in the process of updating an NSIS installation script from XP to Win7. For unknown reasons the installer is not able to write to the registry if running under Win7, even as Administrator. The embedded UAC manifest in the installer is set to require Administrator rights (by specifying RequestExecutionLevel admin in script). Also, I've tried to right-click the installer and selecting Run as administrator. Turning off UAC in OS does not fix the problem either.

When I run the same installer under XP the registry key is written like it is supposed to.

I paired down my install script to try to isolate the problem:

!define APP_NAME      "MyTestApp"

Name                  "${APP_NAME}"
OutFile               "${APP_NAME} Setup.exe"

RequestExecutionLevel admin
Page instfiles

Section -Core
   SetDetailsView show 

   WriteRegStr HKLM "Software\XyzCompany\${APP_NAME}\Installation" "VersionString" "V0.0.0"

   SetAutoClose false
SectionEnd

On the other hand, I am able to write to restricted folders (e.g. C:\ProgramData) (only admin has write access by default here). Am I missing something really obvious here? Running NSIS 2.45.


Solution

  • Use SetRegView to write to the "real" HKLM\Software key on x64.

    Use Process Monitor to investigate other registry write issues...