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

Is it possible to create a registry key regardless of components installed?

Jump to solution

Hello all,

I want to create a registry key for my application, I don't care which of the components is installed as long as if there is ANY component installed. How do I achieve this using a Basic MSI project? I tried executing a Custom PowerShell Action but for some reason it isn't creating a registry key. (using deferred execution in system context)

Labels (1)
0 Kudos
1 Solution
varul
Revenera Moderator Revenera Moderator
Revenera Moderator

You can try our installscript customaction, which will help you achieve your requirement to add registry without any component.

https://docs.revenera.com/installshield26helplib/LangRef/LangrefRegDBCreateKeyEx_example.htm#langref_appendixd_2454617609_1022665

Below Kb article will help you to create a 64bit registry using installscript CustomAction

https://community.flexera.com/t5/InstallShield-Knowledge-Base/Create-a-64-bit-Windows-Registry-Entry-via-an-InstallScript/ta-p/193440

 

View solution in original post

0 Kudos
2 Replies
varul
Revenera Moderator Revenera Moderator
Revenera Moderator

You can try our installscript customaction, which will help you achieve your requirement to add registry without any component.

https://docs.revenera.com/installshield26helplib/LangRef/LangrefRegDBCreateKeyEx_example.htm#langref_appendixd_2454617609_1022665

Below Kb article will help you to create a 64bit registry using installscript CustomAction

https://community.flexera.com/t5/InstallShield-Knowledge-Base/Create-a-64-bit-Windows-Registry-Entry-via-an-InstallScript/ta-p/193440

 

0 Kudos

I'm trying that currently but it's not clear how I can set the value of the registry key to the public property INSTALLDIR, here is the installscript:

 

 

 

#define TITLE_TEXT "RegDBCreateKeyEx & RegDBKeyExist"

#define TITLE "Set Value For Registry Key"

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

 

export prototype CreateCompanyInstallDirRegistryKey(HWND);

 

function CreateCompanyInstallDirRegistryKey(hMSI)

    STRING szKey, szClass, szKeyRoot, szMsg, svLogFile;

    NUMBER nResult1, nResult2;

begin

 

    // Create a key with no class value.

    szKey   = "Gomocha";

    szClass = "";

 

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

        MessageBox ("First call to RegDBCreateKeyEx failed.", SEVERE);

        abort;

    else

        SprintfBox (INFORMATION, TITLE_TEXT, "Successfully created: %s", szKey);

 

        // Check to see if the key just created exists.

        if (RegDBKeyExist (szKey) < 0) then

            MessageBox ("First call to RegDBKeyExist failed.", SEVERE);

        else

            SprintfBox (INFORMATION, TITLE_TEXT, "%s exists.", szKey);

        endif;

    endif;

 

    if (RegDBDeleteKey (szKey) < 0) then

        MessageBox ("RegDBDeleteKey failed.", SEVERE);

    endif;

end;
 

export prototype SetValueForInstallDirRegistryKey(HWND);

 

function SetValueForInstallDirRegistryKey(hMSI)

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

    NUMBER nType, nSize, nvType, nvSize;

begin

	// Set up parameters for call to RegDBSetKeyValueEx.
    szKey = "Gomocha";
    

    szNumName  = "InstallDir";

    szNumValue = INSTALLDIR;

    nType      = REGDB_STRING;

    nSize      = -1;

 

    // Set a key name and a value associated with it.

    if (RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue,

                           nSize) < 0) then

        MessageBox ("RegDBSetKeyValueEx failed.", SEVERE);

        abort;

    else

        // Display what RegDBSetKeyValueEx has done.

        szMsg = "%s set to: %s";

        SprintfBox (INFORMATION, TITLE, szMsg, szNumName, szNumValue);

    endif;

 

    // Retrieve key value information.

    if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue,

                           nvSize) < 0) then

        MessageBox ("RegDBGetKeyValueEx failed.", SEVERE);

    else
 

        // Display what RegDBGetKeyValueEx retrieved.

        szMsg = "%s has value: %s\n\nThis data is %d bytes.";

        SprintfBox (INFORMATION, TITLE, szMsg, szNumName, svNumValue, nvSize);

    endif;

 

 

end;

 

 

 

For some reason the INSTALLDIR value is empty, do I have to pass it in? How do I do this in InstallScript? I assumed it would be a built in variable or something like that. 

0 Kudos