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

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

book

Article ID: 50653

calendar_today

Updated On:

Products

CA Client Automation - Asset Management CA Client Automation - IT Client Manager CA Client Automation CA Client Automation - Software Delivery

Issue/Introduction

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?
 

Environment

Client Automation - Any Versions

Resolution

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.