【问题标题】:vbs all user desktop foldervbs 所有用户桌面文件夹
【发布时间】:2011-08-29 17:53:41
【问题描述】:
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 作为参考。

【问题讨论】:

    标签: file scripting vbscript windows-scripting


    【解决方案1】:

    ObjShellWScript.Shell 时,您可以访问其已实现的SpecialFolders,但随后您将其重新分配给未实现SpecialFolders 的实例Shell.Application,因此会出现错误。

    strCurrentDirectory = objShell.SpecialFolders("AllUsersDesktop")
    

    检索路径,然后:

    Set objFolder = objShell.Namespace(strCurrentDirectory)
    

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

    msgbox objFolder.Title
    

    会回显"Desktop"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-21
      相关资源
      最近更新 更多