获取VBS中的Common Documents文件夹
令我非常懊恼的是,我必须使用 VBS 来编写 InstallShield 2010 LE 自定义操作。我没有 VBS 经验,所以我基本上是将我找到的代码片段放在一起。
我需要获取通用文档文件夹(CSIDL_COMMON_DOCUMENTS)。它未在 WScript.Shell.SpecialFolders
中定义(尽管 All Users Desktop 已定义)。我发现一些尝试链接到系统 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 中运行它时,我在第一行收到以下错误:
Microsoft VBScript 编译错误:预期语句结束
有什么想法吗?
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.
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
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
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从这里
输出窃取:
Stolen from here
output:
忽略 VBScript 自定义操作存在很大问题这一事实,您只需向 WindowsInstaller 询问 CommonAppDataFolder 的位置即可。
CommonAppDataFolder 属性
Ignoring the fact that VBScript custom actions are very problematic, you can just ask WindowsInstaller for the location of the CommonAppDataFolder.
CommonAppDataFolder Property