Creating a custom action that accesses an installed file


Article ID: 180085


Updated On:


Symantec Products




How can I create a custom action that accessess an installed file?


You can create a custom action to access a file that will be installed on the destination computer by the current installation. However, it is important that the file is installed properly on the destination computer before your custom action attempts to use it. Most developers feel that placing the custom action after the InstallFiles action is good enough. In most cases, this is not true.

You can access a file that is already on the computer or a file that is being installed by the package by using a custom action in the product. Many of the custom actions end with From "Installed Files, Destination or Property".  In any case, the following procedures should help you correct some errors caused when accessing a file.

The first possible solution to an error thrown during installation when these custom actions are used (and the one recommended for most situations) is to set your custom action's In-Script Options field to deferred execution. This holds execution of the custom action until the end of the installation sequence. This method should work in most situations because it sets the action to be executed when the queued installation script is executed so it is executed late in the installation after most of the actions have already completed.

The solution above might not work in all situations. If your custom action needs to access properties or table entries in the .msi, deferred execution might not work. In this case, the required files must be installed successfully prior to executing your custom action. To do this, place the custom action after InstallFinalize in the Execute Sequence.

If you cannot place the custom action after InstallFinalize, you must force the installation of the files in the queued installation script prior to your custom action. Windows Installer provides two built-in actions that let you force the execution of all queued installation processes between InstallInitialize and InstallFinalize. These actions are called InstallExecute and InstallExecuteAgain.

To add an InstallExecute or InstallExecuteAgain action:

  1. Go to the Tables tab in Setup Editor.
  2. In the left pane, click on the table that contains the execute sequence containing your custom action. Most commonly, this is the InstallExecuteSequence, which runs for typical installations. If your action is in the Admin Sequence or Advertising Sequence, look at the AdminExecuteSequence or AdvExecuteSequence tables.
  3. Find your custom action in the right pane and determine its sequence number (the number in the Sequence column).
  4. Right-click in the right pane and select New Row. Click OK in the warning dialog if it appears.
  5. In the row that appears, enter InstallExecute or InstallExecuteAgain in the Action column, and enter a sequence number that is less than the sequence number for your custom action. A lower sequence number causes this action to be executed before your custom action.

Now when you run your installation, all of the installation sequence actions prior to your custom action will be executed.