VBS打開當(dāng)前腳本所在文件夾
方法一:Wscript.ScriptFullName
'創(chuàng)建一個(gè) Wscript.Shell 對象的實(shí)例,稍后會(huì)使用這個(gè)對象啟動(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)用下面很簡單的一句話就可以獲取當(dāng)前目錄
currentpath = createobject("Scripting.FileSystemObject").GetFolder(".").Path
或
currentpath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
是不是更簡單呢,這篇文章就分享到這了,希望大家以后多多支持本站。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。