VBS/WMI query CIM_DataFile takes too long RRS feed

  • Question

  • Hello,
    is there a way to make this WQL query faster?

    System is Windows 7 Enterprise/64, normal PC system (a few years old).
    Query execution and "scanning" result list row-by-row (For Each ... Next) needs a very long time.

    Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
       StrWql = "SELECT FROM CIM_DataFile WHERE (Drive = 'C:' OR Drive = 'D:') AND (Extension = 'pst' OR Extension = 'ost')"
       Set colFiles = objWMIService.ExecQuery(StrWql,,48)
          For Each objItem in colFiles
       Set colFiles = Nothing
    Set objWMIService = Nothing

    Thanks and have a nice weekend


    • Moved by Bill_Stewart Tuesday, November 7, 2017 9:44 PM This is not "teach me WMI basics" forum
    Friday, September 15, 2017 8:23 AM

All replies

  • Because you are searching all of two drives.  That will always take a long time.

    Use PowerShell to search as it will be a bit faster.

    Get-ChildItem -Path C:\*,D:\* -Filter *.pst,*.ost


    Friday, September 15, 2017 9:00 AM