I’m trying to create a script to look in a text file and search for something. Then, return a value of “0” if it finds it and returns a value of “1” if it doesn’t. I've found something on scriptcenter, but it just returns the value that I search for. I've modified that script to just output 0 if true and 1 is false, but then I just get a 1 or 0 for each line in the file. I was hoping for the sum of everything which would be 0 if it wasn't found and some number greater than 0 if it was.
Here is what I have so far.
Here is what I have so far.
Code:
Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "ctxsta.dll"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("F:\Program Files\Citrix\Secure Gateway\conf\httpd2.conf", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
Wscript.Echo 0
Else Wscript.Echo 1
End If
Loop
objFile.Close