Video Screencast Help

Adding an External File to an Existing MSI

Created: 19 Mar 2012 • Updated: 19 Mar 2012 | 5 comments
Language Translations
EdT's picture
+3 3 Votes
Login to vote

With a substantial percentage of vendor software now being supplied in MSI format, simple customisation of the MSI can be carried out using the ORCA editor to generate a transform file. ORCA does not insert additional tables, so the risk of any unwanted changes being made is minimised. However, another common requirement is to deploy a configuration file along with the main MSI install, and this challenge can be met in a number of ways.

For example, a custom action can be used to copy the file from the source folder to the installation folder during MSI installation. This implementation requires further actions to handle the uninstall. Alternatively, a custom action can be used to create the file "on the fly", and tools to simplify this process have been covered in some of my other articles. Commonly, an MSI editor such as Wise Package Studio's windows installer editor, can be used to generate a transform and an additional CAB file to deploy alongside the main MSI. These are all valid methods, but I would like to present what I consider to be one of the simplest solutions - achieved by creating the transform entirely with ORCA.

I have used the example of adding the mms.cfg file to an MSI of Adobe Flash's ActiveX install. This file is required in order to stop auto updating.

Adding an external file to an existing MSI with ORCA

It is not uncommon to find that a vendor MSI needs a configuration file to be deployed alongside the main install. This article describes how you can use the ORCA editor to add a file to an existing MSI installation. The file remains uncompressed and is located in the folder containing the MSI and MST.

For my example, I will add the file mms.cfg to the Adobe Flash MSI install. This file is used as part of the process of turning off the autoupdate option, and needs to be installed to the C:\Windows\System32\Macromed\Flash folder

Several table edits are required. Getting the correct values for the required entries can be simplified by using WPS or Adminstudio to add the file to a blank project, compile as an MSI with the media settings set to external file, then lift the settings out of the tables. This method is recommended for the most reliable results, specifically the values for the MSIFileHash table for unversioned files.

To create the necessary transform, first load the Adobe Flash Player 10 ActiveX MSI in ORCA, from the Transform menu, choose New Transform, then edit the following tables:

Directory table:

Note that the MACROMED and FLASH folders are already defined, so we don't need to do anything. However, this would require the source file mms.cfg to be located in a folder tree under the folder containing the MSI. The folder tree would be:<msifolder>.\Windows\System32\Macromed\Flash.

In practice, it is a lot simpler if we can keep the source folder consistent for all files, so in order to achieve this, we need to modify the Directory table further. To enable the mms.cfg file to be located in the same folder as the MSI, the following changes are necessary:

The DefaultDir column permits a format of TargetDirectory:SourceDirectory, so what we need to do is to set the SourceDirectory to . which effectively places the SourceDirectory location one folder 'above' TargetDirectory. This works right up to the WindowsFolder entry in the Directory column, so it finally resolves SourceDirectory as TARGETDIR. This is explained, albeit poorly, in the Windows Installer SDK help file MSI.CHM.

Where a long path exists, this may mean quite a few edits in the Directory table, so it is vital to test that these changes do not affect other parts of the install.

Component table:

Component - mms.cfg
ComponentID - {B3193A92-3299-498A-B83C-BF6AEFD2441E}- use the one created in WPS/Adminstudio, or create one using GUIDGEN (but make sure the GUID is all UPPER case)
Directory - FLASH (you may need to edit the directory table if installing to a folder that does not already exist in the Directory table). The case must match that in the directory table
Attributes - 0 (or whatever else is appropriate to your application - 8 would be used for a registry key path, for example)
Condition - blank, or whatever condition is appropriate to your application Keypath - mms.cfg

This is what it looks like:

CreateFolder table:

Usually only required if you need to create an empty folder.

File table:

File - mms.cfg
Component - mms.cfg
Filename - mms.cfg
Filesize - 24 (from file properties)
Version - add version number if the file has one, otherwise leave blank
Language - add language version or leave blank
Attributes - check what the other files in the file table are using.
NOTE: If the existing files are compressed either internally or in an external CAB file (Check Word Count Summary Property), you will need to add 8192 to the Attributes value for each external uncompressed file, (msidbFileAttributesNoncompressed), to avoid getting a 2920 error
Sequence - increment the last (highest) existing sequence number in the file table.

This is what it looks like:

FeatureComponent table:

Feature - choose the most appropriate feature to add the component to. Note - there is nothing to stop you creating a custom Feature for this addition, but it is rarely necessary in practice. Just make sure you choose a Feature that always gets installed, if there is more than one.
Component - mms.cfg (as used in File Table)

This is what it looks like:

Media table:

DiskId - increment the highest existing value in the Media table
LastSequence - use the sequence value you added in the File Table
DiskPrompt - LABEL
Cabinet - leave blank
VolumeLabel - leave blank
Source - leave blank

This is what it looks like:

MsiFileHash table:

Used for files without a version resource. If the table is not present in the MSI you are editing, then ignore this table. You will need to have used WPS to get the correct hash values here, or one of the windows installer SDK utilities. The Flash MSI does not use this table, so we are done. Save the transform you have created in ORCA, using the Generate Transform option from the Transform menu, and test.

These are the most likely tables that will need updating, but of course it is prudent to go through all the tables if you have used WPS or Adminstudio to 'capture' the addition of the file in question, in case there are other table entries that need to be added. An example of this is the addition of a font file which would also require entries in the Font Table.

Of course this is just an illustrative example. In practice, it is much simpler to just add a one line custom action (Embedded vbscript type 38) which will generate the Unicode file on the fly:

Dim fso, f:Set fso = CreateObject("Scripting.FileSystemObject"):Set f = fso.OpenTextFile("C:\Windows\System32\Macromed\Flash\mms.cfg", 2, True, -1):f.Write "AutoUpdateDisable=1":f.Close

Comments 5 CommentsJump to latest comment

Eshwar's picture

thanks for sharing

Cheers,

Eshwar

0
Login to vote
CableGuy41's picture

Thanks

Thanks,

CableGuy
Do not forget to mark a SOLUTION

0
Login to vote
raj4public's picture

Thanks man. Excellent post . Every information was clear and precise.  Really useful for me to go about in Orca...

0
Login to vote
riva11's picture

Excellent!  Thanks for letting us know.

0
Login to vote
cheldt's picture

thanks, great howto!

0
Login to vote