Is there any way to define wild characters to search for the file like
"*paypal*.txt or just *paypal* to look for files like paypal2.exe or
paypal.word (Any file or extension with paypal in it). Below is the
code I used to search with exact name
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
strComputer = "."
strFilename = "paypal" ' without extension
strExtension = "txt" ' file extension - use lowercase
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select name, extension from
CIM_Datafile where Filename = '"&strFilename&"'")
For Each objFile in colFiles
If objFile.Extension = strExtension then
Wscript.Echo objFile.Name
'nRet = objFSO.DeleteFile(objFile.Name,True)
End If
Next
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++