VBS调用WMI实现搜索硬盘mp3文件
(编辑:jimmy 日期: 2024/12/23 浏览:3 次 )
复制代码 代码如下:
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替换为别的就可以搜索别的文件了。
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
下一篇:用VBS将一篇txt后缀的内容保存为html格式