Home > Blogs > VMware ThinApp Blog

How to add registry keys and custom actions to ThinApp MSI’s

Many organizations with established software packaging practices have standardized their process to include ‘registry branding’ to indicate that an MSI was created by their packaging team, and to populate an area of the Widows registry with information that they can use for inventory purposes.  Adding these custom registry keys to ThinApp generated MSI’s can be done very easily.  Additionally, there may be times when you would like to launch a script, execute a file, or collect some information programmatically as part of the MSI installation process.  Here are the steps you should follow to perform these functions within a ThinApp generated MSI.

Note:  In order to perform these edits, you will need to install Orca, Microsoft’s Free Windows Installer Editor.


Creating custom registry keys

First, open the Template.MSI file from your ThinApp installation directory in Orca.  All edits must be done to the Template.MSI file, you will not be able to successfully edit the MSI file once it has been generated by the ThinApp build process with Orca.


Select the Registry table, and add the following line:


Note that the R0000002 value is used because the ThinApp build process will add its own registry value, and will use the value of R0000001.

Use the following table to determine the ROOT registry value:


For Per-User Installs, the registry value is written under HKCU; Per-Machine is HKLM










In the above example, my key will be written to HKEY_LOCAL_MACHINE\Software\Branding\, and will create a key that is equivalent to the ThinApp Project name, such as “Firefox (VMware ThinApp)”.  You can also fill out the Name and Value fields to create keys as necessary.  See the Registry Table description at MSDN for more information on creating a value other than REG_SZ (String).

Finally, by default ThinApp creates MSI’s with a single Component called ‘Files’.  By adding your registry value to the default component, it will be installed with the rest of the ThinApp package.  Add your key to this component by entering ‘Files’ in the Component column.

Save the Template.MSI file, and try it out with one of your ThinApp packages.  The registry value should be created on install and removed on uninstall.

Creating custom actions

There are many different types of custom actions that can be added with Windows Installer files, and they can be used for a variety of different purposes.  Some installations use them for setting Windows Installer Properties, and running scripts or EXE's.  In this example, I will show how to collect the MAC Addresses from the client that is running the MSI, and add those values to a text file.  To create a custom action, begin again by opening the Template.MSI file in Orca, and this time navigate to the CustomAction Table.


Here you can see that I have added a row to the CustomAction table.  The Action name I used was “WmiMac”, as I will be using the WMI command line interface to collect the MAC Addresses.  I set the Type to ‘34’, using the Custom Action Types page from MSDN as a reference.  Type 34 is defined like this:

Custom Action Type 34

EXE file having a path referencing a directory.


Key to Directory table. This is the working directory for execution.

The Target column is formatted and contains the full path and name of the executable file followed by optional arguments.


Using this information, I set the Source column to “SystemFolder”, and the Target Column to “cmd.exe /c wmic nic get macaddress,description >> C:\macs.txt”, although this example can be generalized to run many more commands.

Because the Source references the Directory table, we will need to make sure that SystemFolder is populated there.  Navigate to the Directory table in Orca.


Here you can see that I have added two more lines, WindowsFolder and SystemFolder.  Follow the example carefully, and be sure to respect the capitalization.  Windows Installer databases are case sensitive.

Finally, we need to add the custom action to the Install Sequence.  Open the InstallExecuteSequence table.


I have added one more row.  The name of the Action is “WmiMac”, as we defined earlier in the CustomAction table.  The Condition is “NOT Installed”.  This is to ensure that the action runs on installation only, and does not run again when the MSI is uninstalled.  Finally, I set the Sequence number to be 6601, or 1 higher than the InstallFinalize Windows Installer Action.  This ensures that the action only runs after the installation succeeds.

Save your MSI file, and try it out by building a ThinApp package that has been configured to also generate an MSI.  If you run into trouble, try logging the MSI installation like this:

Msiexec.exe /I MyThinApp.MSI /Lime MSIERRORS.TXT

The MSIERRORS.TXT file should give you some more information regarding why your installation is failing.  For more information, check the Windows Installer Command Line Reference.