复制代码代码如下:
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