使用VBScript读取txt文件并写入
上一篇 /
下一篇 2011-06-24 17:50:19
'这个是读取文件(文件先存在,否则报错)
Option Explicit
Const ForReading=1,ForWriting=2,ForAppending=8
dim fso,file,msg
Set fso=CreateObject("Scripting.FileSystemObject")
Set file=fso.OpenTextFile("c:\calc.txt",ForReading)
while(Not file.AtEndOfLine)
msg=msg&file.ReadLine&vbCrLf ' 回车符与换行符:vbCrLf=Chr(13)&Chr(10)
Wend
MsgBox msg
file.Close
Set file=Nothing
Set fso=Nothing
'向E盘 result.txt文件中写入(固定)数据
set fso=CreateObject("Scripting.FileSystemObject")
set fw=fso.createtextfile("e:\result.txt",2) '创建txt文件
fw.writeline("vbs123")
fw.writeline("你好,可以吗?")
set ws=CreateObject("wscript.shell")
ws.run "c:\windows\system32\notepad.Exe e:\result.txt"
收藏
举报
TAG: