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 Automation Suite for Data Centers - Configuration Automation CA Client Automation - Asset Management CA Client Automation - IT Client Manager CA Client Automation CA Client Automation - Remote Control CA Client Automation - Asset Intelligence CA Client Automation - Desktop Migration Manager CA Client Automation - Patch Manager CA IT Asset Manager CA Software Asset Manager (CA SAM) ASSET PORTFOLIO MGMT- SERVER CA Server Automation CA Service Management - Asset Portfolio Management CA Service Management - Service Desk Manager

Issue/Introduction

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.

Environment

Release: UASIT.99000-12.5-Asset Intelligence
Component: