当前位置:首页 >> 脚本专栏

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

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