Dim objFSO As New Scripting.FileSystemObject
Dim objFile As Scripting.File '注释:文件对象
Dim objFolder As Folder
Dim strPath As String
strPath = "C:\"
Set objFolder = objFSO.GetFolder(strPath)
'检查目录中的文件
Dim strFileName As String, i As Integer
For Each objFile In objFolder.Files
If objFile.ShortPath, 4 = "file.exe" Then
objFile.DeleteFile "file.exe" ,true
End If
Next objFile