- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- InstallShield - Install Script not setting registry key using RegDBSetKeyValueEx
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
I have a registry key which is storing the software version when I do upgrade or install the software. I am using Install Shield to install the software. I am using following code to set the registry key value, but it's not working. any help would be highly appreciated.
/*--------------------------------------------------------------*\
*
* InstallShield Example Script
*
* Demonstrates the RegDBSetKeyValueEx and RegDBGetKeyValueEx
* functions.
*
* RegDBCreateKeyEx is called to create a test subkey in the
* HKEY_CLASSES_ROOT key. The value of a key is set in integer
* form using the REGDB_NUMBER option of the RegDBSetKeyValueEx
* function. After this value is set, it is retrieved using
* the RegDBGetKeyValueEx function and verified.
*
\*--------------------------------------------------------------*/
#define TITLE "RegDBSetKeyValueEx & RegDBGetKeyValueEx"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_RegDBSetKeyValueEx(HWND);
function ExFn_RegDBSetKeyValueEx(hMSI)
STRING szKey, szNumName, szNumValue, svNumValue, szTitle, szMsg;
NUMBER nType, nSize, nvType, nvSize;
begin
RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
szKey = "SOFTWARE\\Darling Consulting Group\\Darling Data Warehouse";
// Set up parameters for call to RegDBSetKeyValueEx.
szNumName = "ProdVer";
szNumValue = "1.4.52.29";
nType = REGDB_STRING;
nSize = -1;
if (RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE) < 0) then
MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);
else
MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.", INFORMATION);
endif;
if (RegDBKeyExist (szKey) < 0) then
MessageBox ("Second call to RegDBKeyExist failed.", SEVERE);
endif;
// Set a key name and a value associated with it.
if (RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue, nSize) < 0) then
MessageBox(szKey, SEVERE);
MessageBox (szNumName, SEVERE);
MessageBox(szNumValue, SEVERE);
abort;
else
// Display what RegDBSetKeyValueEx has done.
szMsg = "%s set to: %s";
SprintfBox (INFORMATION, TITLE, szMsg, szNumName, szNumValue);
endif;
end;
Hi @jkrall,
Thank you for your post.
Please accept our apologies for the confusion and any frustration.
This is expected behavior due to Windows Registry redirection. The redirection redirects Windows Registry entries to the 32-bit portion (WOW6432Node) of the Windows Registry, unless that redirection is disabled, at least temporarily.
//Use this InstallScript code to temporarily disable Windows Registry redirection, so //the Windows Registry entry will be created under the 64-bit portion of the //Windows Registry.
REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY
//Please make sure to reenable Windows Registry redirection with the following //InstallScript code as soon as you're done creating Windows Registry entries under //the 64-bit portion of the Windows Registry. The redirection will, otherwise, be //disabled until it is reenabled.
REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY
Here is a link to the documentation for REGDB_OPTIONS:
https://docs.revenera.com/installshield28helplib/LangRef/LangrefREGDB_OPTIONS.htm
Please give this suggestion a try. Does this work for you?
Please let us know if you have any questions or concerns. Thanks!
The code works fine in an InstallScript Only InstallShield Pro 2022 R1 project. Which part is not working for you?
The script is not updating the ProdVer value, I am using 2021 R2 and install shield is not Script only, I am using the script as a custom action. I also have entry in the Registry section
Ok, script is creating the key but it's creating in wrong place. I needed it to update an existing key at
SOFTWARE\\Darling Consulting Group\\Darling Data Warehouse
but it's creating at
SOFTWARE\\WOW6432Node\\Darling Consulting Group\\Darling Data Warehouse
any insights how I can enforce the script to update existing key at desired level instead of under WOW6432Node
Hi @jkrall,
Thank you for your post.
Please accept our apologies for the confusion and any frustration.
This is expected behavior due to Windows Registry redirection. The redirection redirects Windows Registry entries to the 32-bit portion (WOW6432Node) of the Windows Registry, unless that redirection is disabled, at least temporarily.
//Use this InstallScript code to temporarily disable Windows Registry redirection, so //the Windows Registry entry will be created under the 64-bit portion of the //Windows Registry.
REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY
//Please make sure to reenable Windows Registry redirection with the following //InstallScript code as soon as you're done creating Windows Registry entries under //the 64-bit portion of the Windows Registry. The redirection will, otherwise, be //disabled until it is reenabled.
REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY
Here is a link to the documentation for REGDB_OPTIONS:
https://docs.revenera.com/installshield28helplib/LangRef/LangrefREGDB_OPTIONS.htm
Please give this suggestion a try. Does this work for you?
Please let us know if you have any questions or concerns. Thanks!