locked
usage of common app data RRS feed

  • Question

  • My app uses the Common Application Data folder to share information between all users – it calls  SHGetSpecialFolderLocation() with parameter CSIDL_COMMON_APPDATA .  On WinXP this works fine, on Win7, the CommonAppData folder gets virtualized if the ACLs are not set correctly so each user gets their own copy of shared data.  This means app-level settings made by one user are not picked up by all other users.  So CommonAppData is NOT Common.

    any help would be appreciated

    Grahame
    Wednesday, December 16, 2009 3:03 PM

Answers

  • The underlying issue is that you're running as a limited user and accessing a location that you don't have rights to, and your access is being virtualised so your program "works". You turn virtualization off by manifesting your program, and in your particular case it seems like you need a manifest with requireAdministrator...

     <requestedPrivileges>
            <requestedExecutionLevel
              level="requireAdministrator"
              uiAccess="false"/>
          </requestedPrivileges>

    This will cause your app to ask the user to elevate to administrator. This is UAC stuff obviously, where even if you are administrator you will not run with administrator privilege unless you elevate somehow. Updating files in the CommonAppDataFolder has always required admin privilege (same with the Program Files folder). Nothing has really changed here except that administrators run as limited user (if they don't elevate) and therefore can't change files in these folders.


    Phil Wilson
    • Proposed as answer by Kira Qian Thursday, December 17, 2009 7:04 AM
    • Marked as answer by Kira Qian Monday, December 28, 2009 8:07 AM
    Thursday, December 17, 2009 12:10 AM

All replies

  • The underlying issue is that you're running as a limited user and accessing a location that you don't have rights to, and your access is being virtualised so your program "works". You turn virtualization off by manifesting your program, and in your particular case it seems like you need a manifest with requireAdministrator...

     <requestedPrivileges>
            <requestedExecutionLevel
              level="requireAdministrator"
              uiAccess="false"/>
          </requestedPrivileges>

    This will cause your app to ask the user to elevate to administrator. This is UAC stuff obviously, where even if you are administrator you will not run with administrator privilege unless you elevate somehow. Updating files in the CommonAppDataFolder has always required admin privilege (same with the Program Files folder). Nothing has really changed here except that administrators run as limited user (if they don't elevate) and therefore can't change files in these folders.


    Phil Wilson
    • Proposed as answer by Kira Qian Thursday, December 17, 2009 7:04 AM
    • Marked as answer by Kira Qian Monday, December 28, 2009 8:07 AM
    Thursday, December 17, 2009 12:10 AM
  • Could you please explain where files that are meant to be read/written to, should be placed in an ALLUSERS install scenario? I do not want to make users have to elevate every time they run my app, so CommonAppDataFolder is out of the question.....?

    FYI, for a current user install, I place the read/write files under LocalAppDataFolder.

    Thank you,
    Radu

    Saturday, March 20, 2010 11:50 PM