Read Each Line of a File with VBScript

A very useful script that will read each line of a text file and output the results. I use this for everything from reading log files and parsing the results to searching files for error messages.

Option Explicit
Dim objFile, strLine
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile= objFSO.OpenTextFile("C:\textfile.txt", 1)
Do While Not objFile.AtEndOfStream
	strLine = objFile.readline
	WScript.Echo strLine
Loop
objFile.Close

Leave a Reply