杰网资源 Design By www.escxy.com

首先是批处理的,很简单,每隔两秒钟读取一行。
复制代码 代码如下:@echo off
for /f "tokens=*" %%i in (lrbf.ini) do (echo %%i & ping -n 2 127.1>nul)
pause

更直观的:
复制代码 代码如下:FOR /F "delims=" %i IN (file.txt) DO echo %i
当然如果你想做更多其他的事 do 后面是你发挥的地方

VBS的两个版本

第一种方式,逐行读取,依次显示:
复制代码 代码如下: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   '这里是显示一行内容而已,可以换成别的内容
loop  
objFile.close  
set   fso=nothing
第二种方式,全部读取,依次显示:
复制代码 代码如下: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   '这里是用echo显示每一行的内容,可以换成别的内容
next  
set   fso=nothing 

VBS读取文本最后一行:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("lrbf.ini", ForReading)
Do Until objFile.AtEndOfStream
strNextLine = objFile.ReadLine
If Len(strNextLine) > 0 Then
strLine = strNextLine
End If
Loop
objFile.Close
Wscript.Echo strLine

标签:
VBS,bat批处理,逐行读取文件

杰网资源 Design By www.escxy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
杰网资源 Design By www.escxy.com