Shortcut for Common Application Folder

What is the shortcut for Common Application Data Folder?

%temp% - temporary file folder
%systemroot% - windows folder
LVL 22
Who is Participating?
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
As the linked article suggests, one should use %ProgramData%, and only if that one does not exist (i.e. XP, 2003 and earlier), fall back to %AllUsersProfile%, but with a modification. The following code will "implement" a ProgramData var if it does not exist.
@echo off
if not defined ProgramData for %%A in ("%AppData%") do set ProgramData=%AllUsersProfile%\%%~nxA

Open in new window

I'm not appending "Application Data" because that is a localized name, and different for non-english countries.
Using the reg method is more save, should the folder have been changed to something completely different:
@echo off
if not defined ProgramData for /F "tokens=3*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Common AppData"') do set ProgramData=%%B

Open in new window

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
List of them:
%ALLUSERSPROFILE% --------------C:\ProgramData
%APPDATA% ----------------------------C:\Users\{username}\AppData\Roaming
%COMMONPROGRAMFILES% -----C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)% --- C:\Program Files (x86)\Common Files
%COMSPEC% -------------------------------C:\Windows\System32\cmd.exe
%HOMEDRIVE% ----------------------------C:
%HOMEPATH% -----------------------------C:\Users\{username}
%LOCALAPPDATA% ------------------------C:\Users\{username}\AppData\Local
%PROGRAMDATA% ------------------------C:\ProgramData
%PROGRAMFILES% ------------------------C:\Program Files
%PROGRAMFILES(X86)% -----------------C:\Program Files (x86) (only in 64-bit version)
%PUBLIC% ------------------------------------C:\Users\Public
%SystemDrive% -----------------------------C:
%SystemRoot% C:\Windows
%TEMP% and %TMP% C:\Users\{username}\AppData\Local\Temp
%USERPROFILE% C:\Users\{username}
%WINDIR% C:\Windows
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

ThomasianAuthor Commented:
%APPDATA% is differnt.

In windows 7, it shows "C:\Users\UserName\AppData\Roaming"
While the common application data folder should be "c:\ProgramData"

Please check link in question for details about common app data folder.
Raheman M. AbdulConnect With a Mentor Senior Infrastructure Support Analyst & Systems DeveloperCommented:
Then its: %PROGRAMDATA% ------------------------C:\ProgramData

to see all the environment variables type:
c:\> SET (enter)
ThomasianAuthor Commented:
%ProgramData% does not work on WinXP

I tried Set but the list doesn't include "c:\Documents and Settings\All Users\Application Data".

Does the command list all available shortcuts?
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
ThomasianAuthor Commented:
Haven't tried it in WinXP yet but it doesn't work on Win7
cantorisConnect With a Mentor Commented:
I know what you're wanting to do but don't know of a built-in easy way.
You could do this in a batch file - as long as you're happy with its path assumptions:
if exist c:\users (
   set AllUsersAppData=c:\ProgramData
) else (
   set AllUsersAppData=c:\Documents and Settings\All Users\Application Data

Open in new window

Or in VBScript using a safer method:
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(COMMONAPPDATA)
Set objFolderItem = objFolder.Self
strAllUsersAppData = objFolderItem.Path

Open in new window

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
In windows 7 : %APPDATA%
%AppData% is the current user's application data, not the common one.

CSIDL_COMMON_APPDATA is not an environment variable under Windows 7 or XP.  It's a special folder location used within the shell by developers.
ThomasianAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.