Getting and Setting MSI Properties from InstallScript

According to InstallShield documentation, getting MSI properties can be done using MsiGetProperty() function:

MsiGetProperty(hMSI, "USERNAME", svName, nvSize);

However, the documentation does not say where to get the value passed throug the hMSI parameter. You discover it only when you start typing. IntelliSense proposes ISMSI_HANDLE as the default value, so:

MsiGetProperty(ISMSI_HANDLE, "USERNAME", svName, nvSize);

Creating a Custom Destination Path for a Component in InstallShield

This article applies to InstallScript projects and explains how to create a custom destination path using script-defined folders or public properties. It is a copy of the original article:

Q104964: Creating a Custom Destination Path

DevStudio 9.x and later users

InstallScript MSI Projects

Follow these steps to create a custom destination path using public properties:

  1. Open the Components view, under Organization.
  2. Select a component to create a custom destination path.
  3. In the Components property window, select the value for the component’s Destination property.
  4. Click the drop down and select “Browse, create, or modify a directory entry…”
  5. In the Browse for Directory window, select the Destination Computer.
  6. Click the Insert (Ins) key and name the folder, for example My Directory.
  7. Set the Directory Identifier to a public property (all capitol letters), for example MY_CUSTOM_PATH.
  8. Make sure to select the new folder My Directory and then click OK.

To define the location of the public property, in the OnFirstUIBefore event handler function, after the begin statement, call the function FeatureSetTarget. For example:

FeatureSetTarget ( MEDIA , "MY_CUSTOM_PATH" , TARGETDISK ^ "customfolder" );

The third parameter of this function should be the custom destination path.

InstallScript Projects

Follow these steps to create a custom destination path using script-defined folder:

  1. Open the Components view, under Organization.
  2. Select a component to create a custom destination path (script-defined folder).
  3. In the Components property window, select the value for the component’s Destination property.
  4. Click the drop down and select “Browse, create, or modify a directory entry…”
  5. In the Browse for Directory window, select Script-defined Folders.
  6. Click the Insert (Ins) key and name the folder, for example <MY_CUSTOM_PATH>.
  7. Make sure to select the new script-defined folder <MY_CUSTOM_PATH> and then click OK.

To define the location of the script-defined folder, in the OnFirstUIBefore event handler function, after the begin statement, call the function FeatureSetTarget. For example:

FeatureSetTarget ( MEDIA , "<MY_CUSTOM_PATH>" , TARGETDISK ^ "customfolder" );

The third parameter of this function should be the custom destination path.

Professional 7.x and 6.x users

Follow these steps to create a custom destination path using script-defined folder:

  1. Open the project workspace’s File Groups pane.
  2. Select a file group to create a custom destination path (script-defined folder).
  3. In the File Groups property and value window, double-click the file group’s Destination property.
  4. In the Destination Properties window, select Script-defined Folders.
  5. Click the New Folder button and name the folder, for example <MY_CUSTOM_PATH>, then click OK.

To define the location of the script-defined folder, in the OnFirstUIBefore event handler function, after the begin statement, call the function ComponentSetTarget. For example:

ComponentSetTarget ( MEDIA , "<MY_CUSTOM_PATH>" , TARGETDISK ^ "customfolder" );

The third parameter of this function should be the custom destination path.

Additional Information

For more information, see Help Library topic FeatureSetTarget.

Microsoft Visual C++ 2010 Redistributable Package (x64) in InstallShield LE

Flexera did not include Microsoft Visual C++ 2010 Redistributable Package (x64) in the “Redstributables” list of InstallShield 2012 Spring LE or InstallShield 2013 LE projects. Perhaps, in order to force us to buy at least the Express version. But there is no need to do that, the issue can be solved in 5 minutes.

First of all, we need to get the corresponding InstallShield Prerequisite file directly from Installshield product site:

http://saturn.installshield.com/is/prerequisites/microsoft visual c++ 2010 redistributable package (x64).prq

Just in case something goes wrong, here is the content of the file:

<?xml version="1.0" encoding="UTF-8"?>
<SetupPrereq>
	<conditions>
		<condition Type="1" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}" FileName="" ReturnValue="" Bits="2"></condition>
	</conditions>
	<operatingsystemconditions>
		<operatingsystemcondition MajorVersion="5" MinorVersion="2" PlatformId="2" CSDVersion="" Bits="4" ProductType="1" ServicePackMajorMin="3"></operatingsystemcondition>
		<operatingsystemcondition MajorVersion="6" MinorVersion="0" PlatformId="2" CSDVersion="" Bits="4" ServicePackMajorMin="2"></operatingsystemcondition>
		<operatingsystemcondition MajorVersion="5" MinorVersion="2" PlatformId="2" CSDVersion="" Bits="4" ProductType="2|3"></operatingsystemcondition>
		<operatingsystemcondition MajorVersion="6" MinorVersion="0" PlatformId="2" CSDVersion="" Bits="4" ProductType="2|3"></operatingsystemcondition>
		<operatingsystemcondition MajorVersion="6" MinorVersion="1" PlatformId="2" CSDVersion="" Bits="4"></operatingsystemcondition>
	</operatingsystemconditions>
	<files>
		<file LocalFile="&lt;ISProductFolder&gt;\SetupPrerequisites\VC 2010 Redist\x64\vcredist_x64.exe" URL="http://download.microsoft.com/download/3/2/2/3224B87F-CFA0-4E70-BDA3-3DE650EFEBA5/vcredist_x64.exe" CheckSum="630D75210B325A280C3352F879297ED5" FileSize="0,5718872"></file>
	</files>
	<execute file="vcredist_x64.exe" cmdline="/q" cmdlinesilent="/q" returncodetoreboot="1641,3010"></execute>
	<properties Id="{8A102FA5-9E73-477b-8937-2ED4C06AF304}" Description="This prerequisite installs the Microsoft Visual C++ 2010 Runtime Libraries (x64)." AltPrqURL="http://saturn.installshield.com/is/prerequisites/microsoft visual c++ 2010 redistributable package (x64).prq"></properties>
	<behavior Reboot="2"></behavior>
</SetupPrereq>

Save it as “Microsoft Visual C++ 2010 Redistributable Package (x64)_.prq” to the SetupPrereqiuisites folder in the InstallShield installation folder. In my case that is:

C:\Program Files (x86)\InstallShield\2013LE\SetupPrerequisites

Note the underline symbol just before the “.prq” in the file name. If you save the file simply as “Microsoft Visual C++ 2010 Redistributable Package (x64).prq”, InstallShield would not “see” it. You have to rename it. Nobody knows why, but that makes the trick. Instead of adding an underline symbol you could name the file as you wish.

If you do not see the the new entry in the list, unblock the “.prq” file BEFORE copying it to the SetupPrereqiuisites folder. To unblock, right-click on the file and click “Unblock” button on the “General” tab.

If you get an error while Visual Studio tries to download redistributable packages, run it “As Administrator”.

That’s it.