VBS调用WMI实现搜索硬盘mp3文件

时间:2022-09-16 13:17:56

复制代码 代码如下:


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where Extension = 'mp3'")
For Each objFile in colFiles
Wscript.Echo objFile.Name
Next


将上面
ExecQuery("Select * from CIM_DataFile where Extension = 'mp3'")
一行中的MP3替换为别的就可以搜索别的文件了。

参考链接:WMI Tasks: Files and Folders
原文:http://demon.tw/programming/vbs-wmi-search-file.html