在VBS中获取Common Documents文件夹

jap*_*iss 2 windows vbscript installer installshield special-folders

令我非常懊恼的是,我必须使用VBS编写InstallShield 2010 LE自定义操作.我没有VBS经验所以我基本上把我找到的代码片段放在一起.

我需要保留Common Documents文件夹(CSIDL_COMMON_DOCUMENTS).它没有定义WScript.Shell.SpecialFolders(尽管所有用户桌面都是).我发现了一些尝试链接到系统DLL的示例代码:

Private Declare Function SHGetFolderPath Lib "shfolder.dll" _
Alias "SHGetFolderPathA" _
    (ByVal hwndOwner As Long, _
    ByVal nFolder As Long, _
    ByVal hToken As Long, _
    ByVal dwReserved As Long, _
    ByVal lpszPath As String) As Long
Run Code Online (Sandbox Code Playgroud)

但是当我尝试在VbsEdit中运行它时,我在第一行得到以下错误:

Microsoft VBScript compilation error: Expected end of statement

有任何想法吗?

Ekk*_*ner 8

这里偷来

  Const CSIDL_COMMON_DOCUMENTS = &h2e
  Dim objShell : Set objShell = CreateObject("Shell.Application")
  WScript.Echo objShell.Namespace(CSIDL_COMMON_DOCUMENTS).Self.Path
Run Code Online (Sandbox Code Playgroud)

输出:

C:\Documents and Settings\All Users\Documents
Run Code Online (Sandbox Code Playgroud)