cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gomochainstall
Level 6

Set multiple registry values through InstallScript

Hello everyone,

In my installer I set multiple registry values through InstallScript, however right now I do this in a less than ideal way:

Here an example on how I set the InstallDir property:

1. I create a CustomAction 'MakePropertiesAvailableForSetRegKeyValueForInstallDir'

     a. I set the Property Name: SetRegKeyValueForInstallDir and the Property Value: [INSTALLDIR]

2. I create a CustomAction 'SetRegKeyValueForInstallDir'

     a. I set the Function Name CreateInstallDirRegistryKeyAndSetValue

3. I add the following code to the InstallScript Setup.rul file:

 

 

export prototype CreateInstallDirRegistryKeyAndSetValue(HWND);

function CreateInstallDirRegistryKeyAndSetValue(hMSI)

    STRING szKey, szNumName, szNumValue, svNumValue, szTitle, szMsg;

    NUMBER nType, nSize, nvType, nvSize;

begin

    szKey = "Gomocha";
    // Create "Gomocha" registry key in HKEY_CLASSES_ROOT

    if (RegDBCreateKeyEx (szKey, "") < 0) then

        MessageBox ("Creating the registry key failed.", SEVERE);

        abort;

    endif;
    
	
	nvSize = MAX_PATH;
	
	MsiGetProperty(hMSI, "CustomActionData", szNumValue, nvSize);

    szNumName  = "InstallDir";

    nType      = REGDB_STRING;

    nSize      = -1;


	RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue, nSize);

end;

 

 

 

This works fine, but I have 26 properties that I want to add in the registry. Is there a more easy way to set these through InstallScript? Can anyone show me a clear example?

 

Ideally I want to setup multiple properties so: [INSTALLDIR],[BACKUPDIR],[SORTIMPORT]

And then loop over them, I just have no clue how to do this in InstallScript. 

I'm using InstallShield 2023 R1.

Labels (1)
0 Kudos
(0) Replies