Where to Store writable data to be shared by all users in a vista installer?
-
02-07-2019 - |
Question
My app is installed via NSIS.
I want the installer to install the program for all users.
I can do this, by installing to the 'program files' directory.
There is a database file (firebird), that all user accounts on the system should share.
If I store this database file in the 'program files' directory it will be read only.
If I store it in the users APPDATA directory they will each have a different copy, when one user adds data the others wont see it.
Option 1 - In my app directory under 'program files' create a 'Data' directory, in my installer make this dir read-writeable by all, that way the user 'program files' virtualisation won't kick in and all users can update the file and see each others changes.
Any other options ?
Solution
Data for all users should be stored in %ALLUSERSPROFILE%, or call SHGetFolderPath() with the parameter CSIDL_COMMON_APPDATA to get the all users storage area.
See http://www.deez.info/sengelha/2006/02/28/windows-vista-changes/ for more details.
OTHER TIPS
Somewhere under the All Users profile would be the obvious location. I think there are some rules about who gets read/write by default, but the MS documentation recommends if you need something different to create a subdirectory and set the ACLs right in the installer.
This is a security hole, see: http://blogs.msdn.com/oldnewthing/archive/2004/11/22/267890.aspx
Specifically I would use:
SetShellVarContext all
SetOutPath $APPDATA
File "MyInsecurelySharedFile.txt"
See the NSIS Scripting Reference for more info.