CommonAppData in vbscript
-
08-07-2019 - |
Question
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?
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow