当前位置: 移动技术网 > IT编程>脚本编程>VBScript > VBS打开当前脚本所在文件夹

VBS打开当前脚本所在文件夹

2020年03月09日  | 移动技术网IT编程  | 我要评论

适应的近义词,保坂尚辉,视频采集卡怎么用

方法一: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

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网