How does MSIX handle the temp folder? And why is it important to know it!
We learned in How does
Files Redirection work with MSIX that user data files, either
from the project or created by executables, are automatically redirected
In this article, we will see how does MSIX handle the temp folder.
There are the two temp folders present on the machine:
- one can be accessed via the environment variable %temp%, which will take you to your user temp folder
- and another per machine temp folder present in C:\Windows\Temp
Let’s see how MSIX handles the temp folders by creating an MSIX
package which has an executable that writes files in both temp folders
and a file %localappdata%\temp folder insides it.
Creating the MSIX project with Advanced Installer
For a better understanding of the following information, you can check bellow how an MSIX package is created with Advanced Installer.
Let’s create a basic MSIX package.
1. Open up Advanced Installer and from the Start Page select New > Installer > MSIX Package.
2. Name it.
3. Choose the location for your project.
4. Create a folder Temp under Local Application Data in the Files and
The %temp% environment variable points to C:\Users\YOURUSER\AppData\Local\Temp
5. In the Temp folder, add a simple text file called TestTempFile.txt
We include this step/operation to see how MSIX packaging handles the user files.
6. Create a simple application called TempApp.exe and add it to the
Application Folder in your project
TempApp.exe creates two files during execution
- TempFile.txt -> created in the user’s temp folder
- TempFile.txt -> created in C:\Windows\Temp
7. Create an application in the Application Details page that points to our TempApp.exe.
8. Configure the build and sign the package
9. Build the package by clicking the build button in the upper left corner
When the application is launched, a confirmation so the files being created appears.
When navigating to the %temp% folder present on the user and in C:\Windows\Temp, both TempFile.txt files created by our TempApp executable are present there.
Remember--we also added the TestTempFile.txt to our project. The reason is for you to find that the file present in the package is redirected, unlike the files created by the TempApp executable.
Did you know that?
You can create FREE MSIX packaging with Advanced Installer Express Edition - the FREE MSIX tool used for building MSIX(APPX) and MSI/EXE packages from the same project, continue serving your Windows 7 users.
Check out more here.
The TestTempFile.txt is a user file. During the first launch, the TestTempFile.txt will be copied to the redirected user data folder: %localappdata%\packages\PublisherName.AppName_hash\LocalCache\Local.
When an executable needs to write data to the user temp folder or machine temp folder, it will not be redirected and will be placed directly into the selected location.
Files created by executables in the temp folders will not be deleted during uninstallation, because they are not redirected and the MSIX package has no knowledge of them.
As a workaround, file redirection with Package Support Framework can be added in the package.
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.