How to handle AppData in MSI using Custom Actions

Written by Alex Marin · April 8th, 2021 · 4min read

Many applications keep settings or configurations in files that later get stored in per-user based locations, such as %appdata% or %localappdata% folders.

NoteFind out more about data storage in our AppData, LocalAppData,ProgramData Explanations, Differences, Use Cases article.

In this article, we will share a good practice to handle appdata that could be helpful for all IT Pros.

To get started, first we will talk about what is included in a cached MSI, and then we will go through our recommended practice of how to place application data within the MSI.

What does a cached MSI include?

When an MSI gets installed on a machine, Windows Installer creates a cached version of it (which can be found in C:\Windows\Installer). We talked more in-depth about this in our article titled "Do not delete your Windows Installer folder".

You will find that the cached MSI only contains the data about Custom Actions, Registry, INI placed from the INI table, File Hashes, etc.

NoteCached versions of the MSI are significantly smaller than the actual MSI, as you can see below.

Cached msi

If you place your files into the Application Data orLocal Application Data folders and then delete the source MSI (during the repair or self-healing process), the Windows Installer will ask you for the location of the source media.

Appdata local appdata
Windows installer source media

To avoid this from happening, the IT Pros community reached a common workaround that you can implement in the MSI - let's see what it is.

Conclusion

If you are an IT Pro, creating a folder in the MSI install directory and using a Custom Action to copy its files in the right location during the repair or self-healing process is a must-do.

You should never rely on the fact that an MSI is located in the machine.

Keep in mind that if it gets deleted and it contains userdata in it, it will give us an error when the Active Setup and Self healing mechanisms start.

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.

Comments: