Differences in %ALLUSERSPROFILE% in Windows XP and Vista+

16,121

I don't know of a good solution for batch-files but I can explain the history.

On Windows 2000/XP/2003 %ALLUSERSPROFILE% is exactly what its name is, the root of the all-users/shared/common profile directory. Typically "C:\Documents and Settings\All Users".

The Windows shell has a special folder constant called CSIDL_COMMON_APPDATA and it typically resolves to "C:\Documents and Settings\All Users\Application Data" but there is unfortunately no environment variable set for this path on these systems.

In Windows Vista and later the documents, music and video folders were moved out of the %ALLUSERSPROFILE% folder and placed in a new folder called Public ("c:\Users\Public") and can be found with %PUBLIC%. CSIDL_COMMON_APPDATA also got a environment variable called %ProgramData% and because most of the other folders moved to %PUBLIC% it was decided that %ALLUSERSPROFILE% did not need the Application Data subfolder so %ProgramData% is the same as %ALLUSERSPROFILE%.

If you are writing a batch-file:

My suggestion is, use %ProgramData% if it exists, otherwise, fall back to %ALLUSERSPROFILE%\Application Data. I don't know if the Application Data folder has a different name on localized versions of Windows...

If you are writing a C/C++ application:

Use SHGetFolderPath.

If you are writing a .NET application:

Use Environment.SpecialFolder.

Share:
16,121
Grodriguez
Author by

Grodriguez

My about me is currently blank.

Updated on June 04, 2022

Comments

  • Grodriguez
    Grodriguez almost 2 years

    Is there an environment variable in Windows that indicates the folder to store application data that is shared by all users?

    In Windows Vista and later, this is %ALLUSERSPROFILE% (typically maps to C:/ProgramData). However in Windows XP, %ALLUSERSPROFILE% maps to C:\Documents and Settings\All Users and I would still need to add something like \Program Data\ to get to the equivalent location.