How to access the registry key HKEY_LOCAL_MACHINE\SOFTWARE in a DMS Script on 64 bit Windows OS?

Document ID : KB000050653
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

Dmscript.exe is a 32 bit executable and every access to HKEY_LOCAL_MACHINE\SOFTWARE key is automatically redirected to the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

Example:

DIM hkey1 AS INTEGER  
hkey1=RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ComputerAssociates\HostUUID")  
IF hkey1=0 THEN   
Print("Could not open registry key HKLM\SOFTWARE\ComputerAssociates\HostUUID")   
END IF  

On a Windows 64 bit machine, this script will open the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ComputerAssociates\HostUUID

How to open the registry keys under HKEY_LOCAL_MACHINE\SOFTWARE without redirection to Wow6432Node on a 64 bit OS?

Solution:

Use function SetMode64(true) to disable the redirection to Wow6432Node

Example:

DIM hkey1 AS INTEGER
SetMode64(True)
hkey1=RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ComputerAssociates\HostUUID")
IF hkey1=0 THEN
Print("Could not open registry key HKLM\SOFTWARE\ComputerAssociates\HostUUID")
END IF

In this example the DMS script will open the key HKLM\SOFTWARE\ComputerAssociates\HostUUID even if it is executed on a 64 bit Windows OS.

Use SetMode64(False) to enable again the redirection to Wow6432Node

Remark:

The function SetMode64() has no effect on a 32 bit machine and the example above is applicable on a 64 bit OS.