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>

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

�/p>

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

是�是更简�呢,这篇文章就分享到这了,希望大家以�多多支�脚本之家�/p>