Sub ReadFiles
Dim fso, f1, ts, s
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("D:\a.txt", True)
'写一行。
msgbox "Writing file
"
f1.WriteLine "Hello World"
f1.WriteBlankLines(1)
f1.Close
' 读取文件的内容。
msgbox "Reading file"
Set ts = fso.OpenTextFile("D:\a.txt", ForReading)
s = ts.ReadLine
msgbox "File contents = '" & s & "'"
ts.Close
End Sub
call readfiles
把以上存为readfile.vbs
即可,ok!!