Recommended application install location



    We're looking into modifying our application(s) to conform with Vista/UAC best practices.


    For example, we have an app, which accesses a SQL Server database. The database currently resides in a program directory, database sub-directory folder.


    In addition, there are several files that currently reside in the program dir folder, such as a configuration/settings ini file, license file, "template file", etc which the application either writes to or creates.


    1. App Database
    What would be the "recommended" location for the database? If this is a per machine database, is it ok to remain in Program Files (keep in mind we have not yet migrated to windows authentication and still using sql server authentication)? Or should this really be installed to %ALLUSERSPROFILE%? And if we consider this a per user database, then it should be installed to %LOCALAPPDATA% or %APPDATA%?


    2. Add'l files that the app writes to
    The same goes for the other files, right? Any files that we determine are per machine, should reside in %ALLUSERSPROFILE%, and/or files that are per user should reside in %LOCALAPPDATA% or %APPDATA%?


    3. App Binary Files
    Finally, what about the application's binary files? If we determine that the application is a per machine application, it can exist in Program Files, but is there a reason we should instead install to %ALLUSERSPROFILE%? If we determine the application is entirely per user, then even installing the application binary files to %LOCALAPPDATA% or %APPDATA% is recommended?


    Thanks, just want to clarify some of the info I've been reading.

    Tuesday, October 02, 2007 8:10 PM


  • The locations are:


    using system.environment

    CommonApplicationData: C:\ProgramData


    using the environment variable

    AllUsersProfile: C:\ProgramData

    Friday, October 19, 2007 12:44 AM

All replies

    • Users run under standard user elevation that means that a standard user can't write to the program files directory.
    • Program files is fine for executables or config files that get written at INSTALL time but not for user updatable data.
    • Application data should go into the %ALLUSERSPROFILE% area under the name of your application
    • If you have per user application data it should go into %APPDATA% or LocalApplicationData


    Below are what comes out if you use the environment in managed code, note that "ExpandEnvironmentVariables" corresponds to what you would get from a set command in the cmd prompt.


    Also note that  %PUBLIC% is not available on XP



    UserName: a-brba
    ApplicationData: C:\Users\a-brba\AppData\Roaming
    CommonApplicationData: C:\ProgramData
    CommonProgramFiles: C:\Program Files\Common Files
    LocalApplicationData: C:\Users\a-brba\AppData\Local
    Personal: C:\Users\a-brba\Documents
    System: C:\Windows\system32
    MyDocuments: C:\Users\a-brba\Documents


    AllUsersProfile: C:\ProgramData
    UserProfile: C:\Users\a-brba
    HomePath: \Users\a-brba
    Public: C:\Users\Public
    AppData: C:\Users\a-brba\AppData\Roaming
    ProgramFiles: C:\Program Files

    Tuesday, October 02, 2007 10:01 PM

    What about the database? Is the recommendation that it be placed in the application data (which can be either per machine or per user) for example, C:\Users\Standard User\AppData\Roaming\Company\Application\Database folder? I'm assuming the answer is Yes.


    Or is it typical to have it exist in a Program Files subdirectory, for example, C:\Program Files\Company\Application\Database?


    Even as a standard user, updating the database while in a program files subdirectory seems to work fine, however, our application at present still uses sql server authentication (rather than windows).


    Finally, it appears there is no LocalAppData environment variable in XP (there is in Vista).  For for the per user application data, would it be best to query the OS, and use AppData for XP and LocalAppData for Vista? Or is it ok to use AppData for both Vista and XP? Which leads to the question -- what are the general guidelines for using "Local" versus "Roaming" in Vista?




    Friday, October 05, 2007 7:13 PM

    Remember, that anything placed in a USER area is PER USER and not per machine. So anything placed in \User\<blah blah>\AppData is only available for THAT user only.


    I shared database should go into the shared area.


    %AllUsersProfile% is actually (right now) <drive:>\ProgramData


    You should place your database file there under your program name, like <drive:>\ProgramData\Myapp\blahblah.db



    Monday, October 08, 2007 7:27 PM
  • The locations are:


    using system.environment

    CommonApplicationData: C:\ProgramData


    using the environment variable

    AllUsersProfile: C:\ProgramData

    Friday, October 19, 2007 12:44 AM
  • Hello,

    Good questions and good answers!

    One question remain unanswered though; best practice "local" vs "roaming" for user data files.

    The Vista Logo test case 15 states that data should be stored in one of these:

    Program Files - %ProgramFiles%

    User’s AppData - %APPDATA%
    ProgramData – %ALLUSERSPROFILE%

    And the %APPDATA% variable points to C:\Users\<User>\Roaming

    Will our app pass TC15 if it uses the local data folders instead?

    Thank you!

    Friday, January 18, 2008 10:37 AM