Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows data storage for all users

Tags:

windows

On Window 7, 8 and 10 I want my app to store data in shared location so all users who run the app on the PC will access the same data. The data are readable/writable. What location should I use?

like image 297
Martin Dusek Avatar asked Nov 13 '16 14:11

Martin Dusek


People also ask

Where is AppData for all Users?

The AppData folder for each user account can be found in the user's directory. For example, if your user name is Joe, you'll find your AppData folder at C:\Users\Joe\AppData by default.

Is there any user data in the Windows folder?

Once you've logged into your Windows machine, you can find all of the data on the computer's “Local Disk (C:) > Users.” When working with corporate machines, it's normal to see multiple users, including Administrator or IT users.

What is user data storage service?

Handles storage of structured user data, including contact info, calendars, messages, and other content. If you stop or disable this service, apps that use this data might not work correctly.


1 Answers

Windows has funny rules regarding program' shared data.

  • Program Files ("C:\Program Files" and "C:\Program Files (x86)") is intended for immutable (read-only) program data and executable files - consequently files here require administrative permissions to edit. Thus it makes it useful for important files that should not be compromised (e.g. your main executable). This is why installers run with elevated permissions. There is a downside in that if your program has an auto-update mechanism then that too needs to run elevated.
  • Program Data (C:\ProgramData on Windows Vista and later, or C:\Documents and Settings\All Users\Application Data) is intended for mutable program data - you don't need administrative permissions to create files in this folder, except that once a file has been created only the user that originally created that file can subsequently edit it (though everyone can read it). This is the special CREATOR OWNER permission.
    • This is described here: Privileges/owner issue when writing in C:\ProgramData\
  • AppData (C:\Users\(you)\AppData\Local and C:\Users\(you)\AppData\Roaming) is user-specific and is intended for user-specific settings, configuration and data. The Local version should be used for machine-specific settings that shouldn't roam if the user is using Roaming Profiles, such as data caches (e.g. a browser cache).

So in your case ProgramData looks ideal, but you need to be careful about the default CREATOR OWNER rules - but there's a workaround: your program's installer (which would run as admin) has the ability to change the ACL permissions on its ProgramData subdirectory to allow other users to edit files. I suggest granting the Users group permission instead of Everyone to prevent possible remote attacks and modifications by unauthenticated users.

like image 156
Dai Avatar answered Oct 31 '22 04:10

Dai