I want to search in a particular folder through all the text files in the folder for the string "Login Failed" then if it is found I want it to copy the file where the string is found to another location. I have the below code but I am getting the error "File not found". Hopefully someone can help.
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell
set objShell = CreateObject("WScript.Shell")
strSearchFor = "Login Failed"
Set oFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\TelnetLogs\Query1"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
strFile = "C:\TelnetLogs\Query1\objFile.Name"
If InStr(oFSO.OpenTextFile(strFile).ReadAll, strSearchFor) > 0 Then
filesys.CopyFile "c:\TelnetLogs\Query1\objFile.Name", "c:\TelnetLogs\Failures\objFile.Name"
Else
WScript.Sleep (100)
END If
Next