Placing Files in the .msi Database and Extracting Them During Run Time

InstallShield 2014

Project: This information applies to the following project types:

Basic MSI
InstallScript MSI

The Support Files view (in Basic MSI projects) and the Support Files/Billboards view (in InstallScript MSI projects) enable you to store temporary files that are to be used by your installation program but are not to be installed. Examples are license text files (as displayed by SdLicense) or DLL files called by your installation. The location to which the support files are extracted at run time is stored in the Windows Installer property SUPPORTDIR.

Note: Deferred, commit, and rollback custom actions in Basic MSI and InstallScript MSI installations have access to only some of the built-in Windows Installer properties: CustomActionData, ProductCode, and UserSID. If you want a custom action to access any other properties (such as SUPPORTDIR) during deferred, commit, or rollback execution, you need to pass them as CustomActionData. To learn more, see Accessing or Setting Windows Installer Properties Through Deferred, Commit, and Rollback Custom Actions.

Project: Note that the value of the Windows Installer property SUPPORTDIR is not the same as the value of the InstallScript system variable SUPPORTDIR.

Custom Action Script Examples

InstallScript

To access a particular support file during installation, Basic MSI projects and InstallScript MSI projects should reference the Windows Installer property SUPPORTDIR. You can use MsiGetProperty to query the path, and then append the file name to the SUPPORTDIR value to obtain the complete path of the file. In the settings for a custom action, this is just [SUPPORTDIR].

In an InstallScript custom action, you could use code such as the following:

export prototype STRING GetSupportFilePathMSI(HWND);

 

function STRING GetSupportFilePathMSI(hMSI)

    STRING szSupportDir[MAX_PATH + 1];

    STRING szMyFile[MAX_PATH + 1];

    NUMBER nLength;

begin

    // set initial buffer size

    nLength = MAX_PATH + 1;

    MsiGetProperty(hMSI, "SUPPORTDIR", szSupportDir, nLength);

 

    // reset buffer-size variable

    nLength = MAX_PATH + 1;

    MsiGetProperty(hMSI, "MYFILE", szMyFile, nLength);

 

    // return full file path

    return szSupportDir ^ szMyFile;

end;

In this example, the name of the support file that is being used is stored in the MYFILE property.

C++

In C++, you could use the following code:

UINT __stdcall ShowSupportdir(MSIHANDLE hInstall)

{

    TCHAR szSupportDir[MAX_PATH + 1] = {'\0'};

    DWORD dwBuff = sizeof(szSupportDir);

    MsiGetProperty(hInstall,"SUPPORTDIR",szSupportDir,&dwBuff);

    MessageBox(NULL,szSupportDir,"SUPPORTDIR is ...",MB_OK);

}

VBScript

In VBScript, you could use the following code:

dim strSupportDir

strSupportDir = Session.Property("SUPPORTDIR")

 

See Also