今天就跟大家聊聊有關(guān)怎么在VBS中打開(kāi)當(dāng)前腳本所在文件夾,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
方法一: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 資源管理器,打開(kāi)腳本所在的文件夾 objShell.Run strPath
方法二:objShell.CurrentDirectory
這種方法代碼少了一些
set objShell = CreateObject("Wscript.Shell") '腳本的當(dāng)前目錄 strPath = objShell.CurrentDirectory strPath = "explorer.exe /e," & strPath objShell.Run strPath
下面是創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,小編的補(bǔ)充
如果是腳本中需要調(diào)用下面很簡(jiǎn)單的一句話就可以獲取當(dāng)前目錄
currentpath = createobject("Scripting.FileSystemObject").GetFolder(".").Path
或
currentpath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
看完上述內(nèi)容,你們對(duì)怎么在VBS中打開(kāi)當(dāng)前腳本所在文件夾有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。