VBS调用WMI实现搜索硬盘mp3文件
程序员文章站
2022-04-29 09:23:30
复制代码 代码如下: strcomputer = "." set objwmiservice = getobject("winmgmts:" _ & "{impersona...
复制代码 代码如下:
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教程:属性-Line 属性