AppData Management in MSI/MSIX/APPV
Let’s assume that you have an application that installs files or registry in a user location. In this article we explain how you can install that information for all users by using MSI, APP-V or the new Microsoft installer technology, MSIX, a short cleanup process description, and a short comparison between them.
MSI
Regarding MSIs, we already have a full article regarding how to deliver a file to all users but let’s do a summary.
In the MSI technology you have 2 approaches:
- Self-healing
- Active setup
The self-healing is one of the main features of Microsoft’s Windows Installer technology. Self-healing leverages the windows installer database cache to allow a full or partial reinstallation of a managed product if the installation somehow becomes broken or corrupt. Windows Installer addresses this feature through Advertised shortcuts
Windows Active Setup is a mechanism for executing commands once per user early during logon. When active setup is used, the following keys are compared:
HKLM\Software\Microsoft\Active Setup\Installed Components\[ProductCode]
HKCU\Software\Microsoft\Active Setup\Installed Components\[ProductCode]
IMPORTANT: Keep in mind that if you have any files to copy into the user location, if you delete the MSI from the original install location the self-healing fails because the files are present inside the MSI. That is why it’s a good practice to place the user files on a machine location (%ProgramFiles%, %ProgramFiles(x86)%, %ProgramData%, etc.), copy them using a custom action script and implement Windows Active Setup within the MSI.
If you only have user registry to place, then it’s recommended to use the self-healing feature by adding Advertised Shortcuts because the media is not needed for repair.
In the MSI technology, at uninstall, all user data created remains on the machine if it’s not specifically deleted from the package by using CustomActions.
IMPORTANT: Because Active Setup only compares the registry keys as mentioned above, it doesn't check if the user files/registry is deleted at uninstall. If you develop a Custom Action that deletes those at uninstall, you must also implement a Custom Action that deletes the HKCU\Software\Microsoft\Active Setup\Installed Components\[ProductCode] key from all users as well or increment the Version registry key, because if you need to reinstall the package, the Active Setup is not triggered again.
APP-V
Starting with APP-V 5.X, the user AppData is copied during the installation in %ProgramData%\App-V\<PkgGUID>\<VerGUID>\Root\VFS.
When the application is started by a user, the AppData is copied into the user profile in %appdata%\Microsoft\AppV\Client\VFS\<PkgGUID>.
The user registry is also imported at first run from the registry.dat file present in %ProgramData%\App-V\<PkgGUID>\<VerGUID>\Root, and you can find it in HKCU\Software\Microsoft\AppV\Client\Packages\<PkgGUID>\<VerGUID>.
Unlike a normal MSI, it doesn’t need extra self-healing/active setup mechanisms, and the media can be deleted after installation because all the necessary files are copied in %ProgramData%.
During uninstall, the user data is not deleted.
MSIX
MSIX, unlike a classic MSI, is installable per user and not per machine, even if the files are saved in %Programfiles%\WindowsApps. Because the MSIX packages are digitally signed, these are installed per user and, no UAC appears. This means that after you install it, you receive the user files as well.
The user files are available in %localappdata%\packages\PublisherName.AppName_hash.
If you look closely %localappdata%\packages\PublisherName.AppName_hash\LocalCache simulates %appdata% and %localappdata% from the user.
All other files are available in %ProgramFiles%\WindowsApps\PublisherName.AppName_AppVersion_architecture_hash
If two or more users are using the same machine, when the first one installs an MSIX all the files are placed in %ProgramFiles%\WindowsApps\PublisherName.AppName_AppVersion_architecture_hash and the Tiles appear in the start menu, but this only publishes the application on that user. If another user signs in, he does not see the tiles, even if the application files are present in %programfiles%, however, if this user installs the same application, the files located in %programfiles% are not overwritten and only a new folder in %localappdata%\packages\PublisherName.AppName_hash is created (presuming that the package contains user data).
The files present on the machine are removed when all the users uninstall the app.
Unlike MSI, when an MSIX package is uninstalled, all the user data is deleted, the one that we import from the package and the one created additionally by the application during its usage.
The registry hive in MSIX is not loaded and cannot be seen in the registry editor, but it can be found in the registry.dat file present in %ProgramFiles%\WindowsApps\PublisherName.AppName_AppVersion_architecture_hash
MSIX is the cleanest solution between the three of them regarding user data cleanup.
Conclusion
As you can see there are some differences between these three technologies:
MSI | MSIX | APP-V | |
---|---|---|---|
Ways of placing AppData to all users | Self-healing mechanism and Active Setup | Each user must install the application in order to be published, and APPDATA placed in %localappdata%\packages\PublisherName.AppName_hash | Places APPDATA in %ProgramData%\App-V\PkgGUID\VerGUID\Root\VFS and copies it automatically on each user %appdata%\Microsoft\AppV\Client\VFS\PkgGUID when executed |
Needs media for self-healing | Yes if user files must be copied | No | No |
Cleans AppData for users at uninstall | No, It can be achieved only using self-developed CustomActions | Yes | No |
In MSI’s you must be careful how you place the user data and be sure to use the approach is best suited for you. The cleanup is a tedious process and, you must use self-developed Custom Actions to achieve that.
The App-V offers a quick and easy solution for the user data, and once it’s sequenced you don’t need to worry about how it’s placed, everything is done automatically by it. However, the cleanup is not so easy.
The MSIX doesn’t offer an automatic solution that can be achievable like the MSI or App-V because an MSIX is a user application, meaning each user must manually install it in order to have access to it. Even if the media is deleted by one user, the other one must get it again in order to install it, so you don’t have to worry about Self-Healing/Active Setup best practices like in the MSI. However, unlike the other solutions, it does a great job of automatically cleaning the system when the application is uninstalled and leave a perfectly clean machine after it.
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.