在VBS中获取Common Documents文件夹 [英] get Common Documents folder in VBS

查看:284
本文介绍了在VBS中获取Common Documents文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

To my great chagrin, I must use VBS to write an InstallShield 2010 LE custom action. I have no VBS experience so I'm basically putting together code snippets that I find.

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

I need to get a hold of the Common Documents folder (CSIDL_COMMON_DOCUMENTS). It's not defined in WScript.Shell.SpecialFolders (although All Users Desktop is). I found some example code that tries to link to a system 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

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

But when I try to run it in VbsEdit, I get the following error on the first line:

Microsoft VBScript compilation error: Expected end of statement

有什么想法吗?

推荐答案

输出:

C:\Documents and Settings\All Users\Documents

这篇关于在VBS中获取Common Documents文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆