2
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strCurrentDirectory = objShell.SpecialFolders("AllUsersDesktop")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strCurrentDirectory)
Set objFolderItem = objFolder.Self
strCurrentDirectory = objShell.SpecialFolders("AllUsersDesktop")

脚本在最后一行崩溃

错误信息是

Microsoft VBScript 运行时错误 (59, 1):对象不支持此属性或方法:'objShell.SpecialFolders'

* 脚本完成 - 退出代码:259 *

我使用http://www.wisesoft.co.uk/scripts/vbscript_display_special_folder_locations.aspx作为参考。

4

1 回答 1

3

什么时候ObjShell是 aWScript.Shell您可以访问其已实现,但您随后将其重新分配给未实现SpecialFolders的实例,因此出现错误。Shell.ApplicationSpecialFolders

strCurrentDirectory = objShell.SpecialFolders("AllUsersDesktop")

检索路径,然后:

Set objFolder = objShell.Namespace(strCurrentDirectory)

将其作为 shell 项获取,例如之后:

msgbox objFolder.Title

会回声"Desktop"

于 2011-05-20T15:07:28.833 回答