First, it's batch, and it's easy to read a row every two seconds.
Copy Code code as follows:
@echo off
for/f "tokens=*"%%i in (Lrbf.ini) do (Echo%%i & Ping-n 2 127.1>nul)
Pause
More intuitive:
Copy Code code as follows:
for/f "delims="%i in (file.txt) do Echo%i
Of course, if you want to do something else, do what's behind you.
Two versions of VBS
The first way, read-by-line, and then display:
Copy Code code as follows:
Const ForReading = 1
Dim objfso,objfile,strline
Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objfile = objFSO.OpenTextFile ("Lrbf.ini", ForReading)
Do Until Objfile.atendofstream
Strline=objfile.readline
WScript.Echo Strline ' Here is a line of content that can be replaced with something else.
Loop
Objfile.close
Set fso=nothing
the second way, read all, and display in turn:
Copy Code code as follows:
Const ForReading = 1
Dim objfso,objfile,strline
Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objfile = objFSO.OpenTextFile ("Lrbf.ini", ForReading)
Str=objfile.readall
Objfile.close
If str= "" Then
WScript.Echo "Nothing"
Wscript.Quit
End If
Strarry=split (STR,VBCRLF)
For each linestr in Strarry
WScript.Echo Linestr ' Here is an echo showing the contents of each row, and can be replaced with something else.
Next
Set fso=nothing
VBS reads the last line of text:
Const ForReading = 1
Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objfile = objFSO.OpenTextFile ("Lrbf.ini", ForReading)
do Until
Objfile.atendofstream = strnextline Le. ReadLine
If Len (strnextline) > 0 Then
strLine = strnextline
End If
Loop
Objfile.close
WSCRIPT.E Cho strLine