VBS打开当前脚本所在文件夹 |
|
方法一: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 这种方法代码少了一?/p>
set objShell = CreateObject("Wscript.Shell")
'脚本的当前目?
strPath = objShell.CurrentDirectory
strPath = "explorer.exe /e," & strPath
objShell.Run strPath
下面是脚本之家小编的补充 如果是脚本中需要调用下面很简单的一句话就可以获取当前目?/p>
?/p>
是不是更简单呢,这篇文章就分享到这了,希望大家以后多多支持脚本之家?/p> |