欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VBS打開當(dāng)前腳本所在文件夾

 更新時(shí)間:2019年12月08日 14:14:37   作者:一株禾  
有時(shí)候我們需要獲取當(dāng)前vbs腳本所在的文件夾,或者運(yùn)行當(dāng)前腳本文件夾中的文件那么就需要參考下面的代碼了

方法一:Wscript.ScriptFullName

'創(chuàng)建一個(gè) Wscript.Shell 對(duì)象的實(shí)例,稍后會(huì)使用這個(gè)對(duì)象啟動(dòng) Windows 資源管理器
Set objShell = CreateObject("Wscript.Shell")
'獲取腳本的路徑
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
'獲取腳本當(dāng)前所在文件夾的路徑
strFolder = objFSO.GetParentFolderName(objFile) 
strPath = "explorer.exe /e," & strFolder
'啟動(dòng) Windows 資源管理器,打開腳本所在的文件夾
objShell.Run strPath

方法二:objShell.CurrentDirectory

這種方法代碼少了一些

set objShell = CreateObject("Wscript.Shell")
'腳本的當(dāng)前目錄
strPath = objShell.CurrentDirectory
strPath = "explorer.exe /e," & strPath
objShell.Run strPath

下面是腳本之家小編的補(bǔ)充

如果是腳本中需要調(diào)用下面很簡(jiǎn)單的一句話就可以獲取當(dāng)前目錄

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

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

是不是更簡(jiǎn)單呢,這篇文章就分享到這了,希望大家以后多多支持腳本之家。

相關(guān)文章

最新評(píng)論