geting special folders with shell.application

≡放荡痞女 提交于 2019-12-04 20:48:34
Helen

You need to use Shell.Namespace(...).Self.Path:

Const ssfDESKTOPDIRECTORY = &h10
Set oShell = CreateObject("Shell.Application")
strDesktop = oShell.NameSpace(ssfDESKTOPDIRECTORY).Self.Path

WScript.Echo strDesktop


But for my script this will not work as I cant use WScript.

Do you mean you can't use WScript.CreateObject(...) because WScript is undefined? If so, you can simply use CreateObject("WScript.Shell").SpecialFolders("Desktop") instead. See What is the difference between CreateObject and Wscript.CreateObject?.

Try the namespace method:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(&H10&)

Where &H10& is a special folder constant for the desktop. See technet for a list of all special folder constants.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!