2008-11-17 5 views
7

L'application "AppName" d'un client a ses fichiers de configuration stockés dans CommonAppData.CommonAppData dans vbscript

  • Sous Windows XP est C:\Documents and Settings\All Users\Application Data\AppName
  • Sous Windows Vista qui est C:\ProgramData\AppName

Comment puis-je obtenir la foldername correcte avec VBScript?

Répondre

11
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 

Le MSDN détient une page qui répertorie l'autre Shell Special Folder Constants.

Cette page est également intéressante: Enumerating Special Folders, qui fait partie du Microsoft Windows 2000 Scripting Guide.

+1

Merci! Tu as sauvé ma journée. ;-) – Mephisztoe