CommonAppData in vbscript

A customer's application "AppName" has its configuration files stored in CommonAppData.

  • Under Windows XP that is C:\Documents and Settings\All Users\Application Data\AppName
  • Under Windows Vista that is C:\ProgramData\AppName

How do I get the correct foldername with VBScript?


Const CommonAppData = &H23&  ' the second & denotes a long integer '

Set objShell  = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(CommonAppData)

Set objFolderItem = objFolder.Self

MsgBox objFolderItem.Name & ": " & objFolderItem.Path

The MSDN holds a page that lists the other Shell Special Folder Constants.

This page is nice, too: Enumerating Special Folders, part of the Microsoft Windows 2000 Scripting Guide.


 ? C++ atof/_wtof, rounding error
 ? Why does UpdateData() not work in EN_CHANGE handler for MFC CEdit control
 ? Is there a safe way to cast DWORD_PTR into DWORD?
 ? XPosed: Hooking a function overridden in an enum
 ? Bitmap.Save "Generic Error"
 ? When are C# Draw/Fill functions called? How can they be invoked from a separate class?
 ? How to hide System.Drawing line with condition
 ? Reading a file as a 2d char array
 ? [vue]use semantic.min.css icon font error: Failed to decode downloaded font: http://localhost:10001/font/icons.woff2
 ? Cross-browser CSS issue when changing font-weight