Writing registry value in a 64-bit system
Asked Answered
C

1

10

I have an application setup build in NSIS. The set requires a key to be created at the following location for my application to start:- HKEY_LOCAL_MACHINE\Software\\\" "VersionNo" 0 HKEY_LOCAL_MACHINE\Software\Wow6432Node\\" "VersionNo" "11"

In the script, i have used:-

      WriteRegDWORD HKLM "SOFTWARE\<Key1>\<Key2>\<Key3>" "VersionNo" 0
      WriteRegStr HKLM "SOFTWARE\<Key1>\<Key2>" "VersionNo" "11"

This key is created successfully on a 32-bit Windows 7 system. However, when i install the setup on a 64-bit Windows 7 system the key is not created in the above location. Instead it creates the key at:-

      HKEY_LOCAL_MACHINE\Software\Wow6432Node\<Key1>\<Key2>\<Key3>" "VersionNo" 0
      HKEY_LOCAL_MACHINE\Software\Wow6432Node\<Key1>\<Key2>" "VersionNo" "11"

This results in my application not starting after installation.

--Can someone please suggest command/script for NSIS to compulsorily create the key(s) under HKEY_LOCAL_MACHINE\Software\ for a 64-bit system instead of it getting created under HKEY_LOCAL_MACHINE\Software\Wow6432Node?

Eagerly waiting for a solution....

Cirrhosis answered 22/6, 2012 at 4:35 Comment(0)
N
37

Use SetRegView to switch between 32-bit and 64-bit registry. Your code should looks like:

SetRegView 64
WriteRegDWORD HKLM "SOFTWARE\<Key1>\<Key2>" "VersionNo" 0
SetRegView 32
WriteRegStr HKLM "SOFTWARE\<Key1>\<Key2>" "VersionNo" "11"
Nickienicklaus answered 22/6, 2012 at 4:45 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.