Summary
This article discusses how to specify a condition for checking the Windows Registry in the case of a variable Windows Registry path.
Project Type
Basic MSI
Problem Description
During installation of software, the DatabaseFolder Dialog is displayed and the user may choose a folder and that folder path is stored in the [DATABASEDIR] property.
From this, a registry value is created:
Path = "HKEY_LOCAL_MACHINE\SOFTWARE\TEST Abc\[REGISTRY_SETUP_PATH]"
where [REGISTRY_SETUP_PATH] is a property that will be set to different values depending on release flags
The value name = "CommonFilesPath"
The value data = "[DATABASEDIR][CommonFilesDirectoryName]"
[DATABASEDIR]= Value entered in dialog "DatabaseFolder"
[CommonFilesDirectoryName]= Property that will be set to different values depending on release flags.
What is the condition if this Windows Registry value "CommonFilesPath" on path "HKEY_LOCAL_MACHINE\SOFTWARE\TEST Abc\[REGISTRY_SETUP_PATH]" already exists before then install starts? In this case this Windows Registry value should not be modified and the DatabaseFolder Dialog should not be displayed.
Solution
This can be achieved by using the following InstallScript code:
1. RegDBGetKeyValueEx - Use this function to get the Windows Registry value.
function CheckIfCFRegistryValueExists(hMSI) STRING sRegistrySetupPath; NUMBER nRegistrySetupPathSize, nType; STRING sRegKey, sRegName, sRegValue, sErrorCode, szMsg; NUMBER nRegType, nRegSize, nErrorCode; STRING sCFRegistryValueExists; NUMBER nCFRegistryValueExistsSize; begin //Find exact path to registry. MsiGetProperty (hMSI, "REGISTRY_SETUP_PATH", sRegistrySetupPath, nRegistrySetupPathSize); RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); REGDB_OPTIONS = REGDB_OPTION_WOW64_64KEY; sRegKey = "SOFTWARE\\TEST Abc\\" + sRegistrySetupPath; sRegName = "CommonFilesPath"; sRegValue = "NONE"; nRegType = REGDB_STRING; nRegSize = -1; //Get value from registry if (RegDBGetKeyValueEx (sRegKey, sRegName, nRegType, sRegValue, nRegSize) < 0) then //Registry value doesn't exists. Set CFRegistryValueExists to "FALSE" MsiSetProperty(hMSI, "CFRegistryValueExists", "FALSE"); else //Registry value exists. Set CFRegistryValueExists to "TRUE" MsiSetProperty(hMSI, "CFRegistryValueExists", "TRUE"); endif; MsiGetProperty (hMSI, "CFRegistryValueExists", sCFRegistryValueExists, nCFRegistryValueExistsSize); end;
Note: The InstallScript code is triggered by an InstallScript custom action configured for Immediate Execution.
2. Add a condition for the DatabaseFolder Dialog.
The condition should be specified for the NewDialog Event the Next button that navigates to the DatabaseFolder Dialog.
In this case, the condition would be: NOT CFRegistryValueExists
Related Articles
FlexNet inventory agent may not return any Oracle inventory on Windows if the %TEMP% environment variable resolves to a pa… 4Number of Views Locating MSI Upgrade Codes in the Windows Registry 5Number of Views Windows Update KB3072630 causes Registry permission changes to HKCU to fail 16Number of Views Create a Windows Registry Entry with Type REG_NONE for Windows File Type Association 6Number of Views Create a 64-bit Windows Registry Entry via an InstallScript Custom Action 9Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago