3 Ways of Handling User Resources in MSI: Self-Repair, Active-Setup, CustomAction
As IT Pros, we deal with all sorts of application installers developed by different software vendors. We also need to configure and customize each of those applications to fit our organization's needs.
Most of the time, the configurations and customizations we make get stored in either a file located under the user profile (ie %localappdata% folder) or a registry key under HKEY_CURRENT USER (HKCU).
Whether we talk about HKCU registry keys or user files, we have three options to deliver those directly to the end-user within the MSI by using:
In this article, we’ll go through each of these options and see how you can use them in Advanced Installer to deliver user resources.
How to use Self-Repair to deliver user resources?
Resiliency is the ability of an MSI Windows Installer package to repair itself and recover from a scenario where a feature, component, file (or file version) or a registry key is missing or broken.
You can trigger the Self-Repair (or Self-Healing) option in several ways. However, the most common way to activate it’s through an Advertised Shortcut.
How does Self-Repair work?
When activated, the Advertised Shortcut triggers a check of all the key paths of the components located within the same Feature and the parent Feature. If any keypath is missing or broken, then it triggers the Self-Repair.
The Self-Repair progress bar looks similar to the installation and uninstallation progress bars (in case you install/uninstall your application without a UI).
Now that we know what Self-Repair is and how it works, let's see what we need to do in order to deliver user resources.
1. Go to the “Organization” page and there make sure that the Feature is set to "Allow
2. In the Shortcuts page view, and check the “Advertised shortcut” option.
3. Make sure that each component has the appropriate keypath set to it.
And that’s it!
After you complete these steps, the user resources will be delivered to each user profile when the end-user launches the application.
The DISABLE ADVT SHORTCUTS property disables the shortcut advertisement. Pay attention to this property, especially when working with vendor MSI, where you need to set the shortcuts as advertised.
If you want to test the behavior, the easiest way is to install the MSI from System context using PsExec and then launch your shortcut.
How to use Active-Setup to handle user resources?
There are some scenarios where your application has no shortcuts or you don’t want to set them as Advertised.
In this case, you can use Active-Setup to make sure that the end-user has access to the user resources of your application.
Active-Setup is a mechanism that can be used to trigger a specific action to be run once per user at logon time.
How does Active-Setup work?
1. The OS logon process looks at all subkeys under the following
HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\[ID].
2. Then, it checks for a corresponding subkey under HKCU
HKEY_CURRENT_USER\Software\Microsoft\Active Setup\Installed Components\[ID]
3. For each subkey not found under HKCU, it executes the action and then it adds it to HKEY_CURRENT_USER\Software\Microsoft\Active Setup\Installed Components so that it will not execute again.
The Active-Setup registry key includes multiple registry values that you can use. However, the most common ones are:
- (Default) – specifies the display name of the action
- StubPath – specifies the command to be executed
- Version – specifies the version. The command runs only if the corresponding version under HKCU is smaller or not present at all.
Your registry hive should look like the one below:
And that’s all. On the next log on, the user resources will be delivered to each user profile.
How to add configure the ActiveSetup in Advanced Installer?
You can add and configure the ActiveSetup straight from Advanced Installer’s GUI by going to the Product Details page and then to the Active Setup tab.
If the StubPath command uses msiexec, you must take the msiexec repair parameters into consideration when you set it up.
If you want to test the behavior, the easiest way is to install the MSI from System context using PsExec, then log off and log back in.
How to use CustomAction to deliver user resources?
If you're still looking for an alternative option to deliver user resources, you can try CustomActions.
To use this method, first create a custom action and then set it to be run only on REPAIR.
For example, this option is used if the user resources are generated dynamically and you cannot include them in the package – you can still generate them from the command line (e.g. using a utility tool provided by the vendor).
Let’s suppose that the application needs to be registered and the registration information is stored per-user. We have the following VBScript to run the registration command silently.
Dim objShell Set objShell = WScript.CreateObject( "WScript.Shell" ) objShell.Run("""%ProgramFiles%\MyCompany\MyApp\RegMyApp.exe""") Set objShell = Nothing
Then, include this script as a CustomAction (don’t forget to set it to execute on Repair only).
What does this mean?
- If the application has a shortcut, the CustomAction gets executed when the end-user launches the shortcut for the first time (providing that the shortcut is set as Advertised).
- If the application does not have a shortcut, you can get it triggered via ActiveSetup, as we did earlier.
As you can see, there is no one-size-fits-all option to deliver the user resources of your application.
When it comes to delivering user resources, you may see that the Active-Setup is the go-to method since Advanced Installer provides an excellent end-user experience - users can start your application right away without needing to log off and then log back on.
What option do you use most often? Leave us a comment below!
Subscribe to Our Newsletter
Sign up for free and be the first to receive the latest news, videos, exclusive How-Tos, and guides from Advanced Installer.