幽灵资源网 Design By www.bzswh.com

方法一:Wscript.ScriptFullName

'创建一个 Wscript.Shell 对象的实例,稍后会使用这个对象启动 Windows 资源管理器
Set objShell = CreateObject("Wscript.Shell")
'获取脚本的路径
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
'获取脚本当前所在文件夹的路径
strFolder = objFSO.GetParentFolderName(objFile) 
strPath = "explorer.exe /e," & strFolder
'启动 Windows 资源管理器,打开脚本所在的文件夹
objShell.Run strPath

方法二:objShell.CurrentDirectory

这种方法代码少了一些

set objShell = CreateObject("Wscript.Shell")
'脚本的当前目录
strPath = objShell.CurrentDirectory
strPath = "explorer.exe /e," & strPath
objShell.Run strPath

下面是小编的补充

如果是脚本中需要调用下面很简单的一句话就可以获取当前目录

currentpath = createobject("Scripting.FileSystemObject").GetFolder(".").Path

currentpath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path

是不是更简单呢,这篇文章就分享到这了,希望大家以后多多支持。

标签:
VBS打开当前文件夹

幽灵资源网 Design By www.bzswh.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
幽灵资源网 Design By www.bzswh.com