Difference between Program Files and ProgramData?

15,712

Program Files is for executables and other static files that came as part of the installation. ProgramData is for user-agnostic data generated during execution such as shared cache, shared databases, shared settings, shared preferences, etc. User-specific data goes in the AppData folder. Note that these are for non-user-visible data. User-visible data belongs in the documents folder (or music, video, custom sibling folder, etc.).

Please see Special Folders and Custom Folders for a detailed explanation. Note that the terminology used varies slightly between the name used in the documentation here, the name of the folder, and the name used by various enumerations used to get these paths from the system.

Share:
15,712
M.M
Author by

M.M

Professional C programmer for 21 years, mostly on embedded systems. Some Windows C++ development also.

Updated on July 25, 2022

Comments

  • M.M
    M.M almost 2 years

    How do I decide which of my application's files go in Program Files (FOLDERID_ProgramFilesX64) and which go in ProgramData? (FOLDERID_ProgramData)? I don't understand what the reason is for splitting up my application's fixed files into these two categories or how I should decide which file goes in what.

    For example - image files which my application displays, are they "program" or "data"?

    Is there any problem with just putting everything under one or the other?

    The application is installed for All Users and has no user-specific configuration files or data.

  • M.M
    M.M over 9 years
    As discussed on this thread , ProgramData defaults to not being writable by the application at runtime in Windows 7. So the installer must do an ACL hack and give world-writable permissions to its folder under ProgramData; all of this suggests that actually it was not intended to be used the way you say, hence my confusion!
  • James
    James over 9 years
    I've edited to clarify--ProgramData is for data that is shared across all user accounts. There's yet another location (AppData) for user-specific data. Please see the link I added for full details. Yes, lower-privilege users may not have rights to edit the shared data.
  • M.M
    M.M over 9 years
    I still don't follow. If a non-admin user is running the application then is it expected the application asks for UAC elevation to write its shared cache?
  • James
    James over 9 years
    Yes. Cache and settings that are shared across users are generally a rare thing. Since changing those could affect other users, UAC elevation is required. This is similar to the protections the OS puts in place to prevent one bad program from reading data from or writing data to another process. The separation of different types of data allows developers to decide which items should be shared and which ones should not. Cache can often contain user-specific data, which shouldn't be able to be read by other users.
  • Harry Johnston
    Harry Johnston over 9 years
    The permissions on the ProgramData directory (and the default permissions on subdirectories) allow any user to create new directories and files. This means you can create a directory at runtime without elevation, so your installer does not need to do it for you. The default permissions on files allow anyone to read them but only the creator can write to them. The answer on the other thread is wrong.