Well it's always a good idea to actually open the file first!
Dim objFile, tmpStr, objFSO
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile= objFSO.OpenTextFile("C:\Users\Desktop\TS.txt", ForReading)
Then you can read it line by line if your really want to...
Do While Not objFile.AtEndOfStream
tmpStr = objFile.readline
' Do your checks in here
Loop
objFile.Close
Or you could just read in the entire file
tmpStr = objFile.ReadAll
Your next problem is the stuff you are trying to find
substrToFind = "2w" & "fr" & "6J"
will actually result in you trying to find the string
"2wfr6J"
- I don't think that is really what you mean. You should search for 2w, fr and 6J separately.
Dim b1, b2, b3
b1 = False : b2 = False : b3 = False
Const vbTextCompare = 1
If Instr(1, tmpStr, "2w", vbTextCompare) > 0 Then
b1 = True
End If
If Instr(1, tmpStr, "fr", vbTextCompare) > 0 Then
b2 = True
End If
If Instr(1, tmpStr, "6J", vbTextCompare) > 0 Then
b3 = True
End If
If b1 And b2 And b3 Then
WScript.Echo "Found"
End If
Also note that I've made the search do a text search - the default for Instr is binary.
Finally, here is some reference material - always a good place to start
VBScript - OpenTextFile Method[
^]
VBScript - ReadAll Method[
^]
VBScript - InStr Function[
^]