AppData | LocalAppData | ProgramData Explanations, Differences, Use Cases
In this article, we go through:
- understanding what an environment variable is
- what is its purpose
- what’s up with our mentioned AppData, LocalAppData & ProgramData
- what do they have in common but also what are the particularities of each one
- and, last but not least, how does this apply in the case of an MSIX application in a Modern Desktop & Workplace environment
What is the environment variable?
An environment variable is a variable with a dynamically defined value that depends on the context/environment that it is being used (OS, logged in user, etc.).
To easily understand this, let’s do a simple exercise together:
- On your Windows machine, open cmd.exe, type SET, and press enter. This command lists your current session environment variables
- Take a look over what variables and values I got and try to compare with your results. Can you find similar ones? Also, do you spot the differences?
- Let’s take ProgramFiles & ProgramFiles(x86) for example. If you have Windows 10 64bit just as I do, we should expect the same values. If you have Windows 10 32bit, only ProgramFiles should be present on your list.
- Now let’s look over COMPUTERNAME and USERNAME. I bet your computer doesn’t have the same name as mine, and chances are your user name is also different since we are different people
As you can see, an evironment variable can:
- define a value used for describing an object COMPUTERNAME
- define a dynamic windows location path (APPDATA) and each window session has different variables depending on which user is logged in, on what computer, what number of processors the computer has and so on.
What AppData, LocalAppData & ProgramData have in common?
Besides the fact that we have just learned that AppData Local, AppData, and ProgramData are environmental variables, there is another thing they have in common: they define location paths where an application stores data.
Which location is used by an application? It all depends on how an application is developed and what kind of information it stores.
Let’s dive in and see each environmental variable in particular.
Open a file explorer and type %appdata% in the path. Do this also for LocalAppData & Program data and see where it takes you
1. %AppData%
Accessing %appdata%, leads to C:\Users\Radu Popescu\AppData\Roaming. Here a lot of the applications store their settings under the current logged in user.
Noticed “Radu Popescu” in the path? Previously, I asked you to access %appdata%. Because you opened it on your computer under your own user account, you should see your username there.
This means that each %appdata% is specific for every user. For this reason, %appdata% is security restricted. Therefore you cannot access others %appdata% (not unless you have a fully privileged user account or you know the credentials for that specific user).
If you work in a company and the computer is joined to a domain, you need to know that the %appdata% folder is synchronized over the network. This is very helpful when you move to a new computer or access another device, and you want your data to be preserved.
This being said, %appdata% is a suitable location to store application data for a user with multiple computers that wants to cross share application information between the devices - Roaming.
2. %LocalAppData%
Accessing %localappdata%, leads to C:\Users\Radu Popescu\AppData\Local. Same as %appdata%, a lot of applications store their settings under the current logged in user.
The location is also security restricted, being unique for each user.
Do you notice the “Local” at the end of the path? This gives us a hint: the data stays local. It doesn’t synchronize application data over the network even if the computer is joined to a domain.
This is a good reason to choose %localappdata% as a store location for user application settings. In case your files are large and you don’t want to create a busy network and a long-time user profile synchronization between the computers that you access with the same account.
So, %localappdata% is a suitable location to store data for an application that is used only on one machine by a single or multiple users and also for big sized files.
3. %ProgramData%
%ProgramData% points to C:\ProgramData. By default, the folder is hidden. Here applications store data that applies for all users on the machine.
If you open file explorer and type C:\Users\All Users, you get redirected to %ProgramData% path. Therefore this location is preferred for applications that store data for all users with no security access restriction.
How does this apply to MSIX?
The default install folder for an MSIX application is
C:\Program FIles\WindowsApps.
But since we know that an MSIX is
installed per user, the user files are stored under:
%localappdata%\packages\PublisherName.AppName_hash.
Now, because MSIX runs in a containerized environment and is installed per user, an %appdata% inside %appdata% is simulated. We can check this out by opening a file explorer and navigate to the Local Cache of our MSIX application.
Notice the Local and Roaming folders inside? It’s just like in our case of %appdata% and %localappdata%.
For a full %appdata% management in MSI/MSIX/App-V, check you this blog article.
Video Tutorial
AppData | LocalAppData | ProgramData : FAQ
What is the AppData Folder
The AppData folder is a hidden per-user folder that stores application data. It is typically located in the following directory: C:\Users\USERNAME\AppData.
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.