CODE: [Copy to clipboard]
'在打开C盘文件的时候,好像有权限不允许吧!不知道
'因为是全盘搜索,所以搜索速度还是很慢的!
On Error Resume Next
num=0
Set fso=CreateObject("Scripting.FileSystemObject")
Set dc=fso.Drives
For Each d in dc
If d.isready Then seek d
Next
If num=0 Then
MsgBox "一个都没发现啊!!"
Else
MsgBox "搜索完毕了"&vbCr&"搜索到了"&num&"个这样的文件"
End If
Set fso=Nothing
Function seek(tar)
Set fso=CreateObject("Scripting.FileSystemObject")
Set WS=CreateObject("Wscript.Shell")
Set curF=fso.GetFolder(tar)
'当前目录下的文件
If curF.Files.count > 0 Then
For Each file In curF.Files
If fso.GetExtensionName(file)="inf" Then ws.Run "notepad.exe "&file
num=num+1
Next
End If
'当前目录的子文件夹
If curF.SubFolders.count > 0 Then
For Each subF In curF.SubFolders
'递归算法
seek subF
Next
End If
Set WS=Nothing
Set fso =Nothing
End Function