写了一个接受命令行参数的VBS,用于读取文本的某一行,比如输入cscript
test.vbs test.txt 1即读取test.txt的第一行字符串,但是不知道哪里出错了,请各
位达人帮忙看下:
If WScript.Arguments.Count=0 Then
WScript.Echo "Sorry,参数错误."
WScript.Quit
End If
Dim arr()
Dim objFSO,objFile,WSH
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSH=WScript.Arguments
Set objFile = objFSO.OpenTextFile(WSH(0), 1)
Do Until objFile.AtEndOfStream
For i=1 To WSH.Count-1
If objFile.Line = WSH(i) Then
theline=objFile.ReadLine
WScript.Echo theline
End If
Next
objFile.SkipLine
Loop
objFile.Close
test.vbs test.txt 1即读取test.txt的第一行字符串,但是不知道哪里出错了,请各
位达人帮忙看下:
If WScript.Arguments.Count=0 Then
WScript.Echo "Sorry,参数错误."
WScript.Quit
End If
Dim arr()
Dim objFSO,objFile,WSH
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSH=WScript.Arguments
Set objFile = objFSO.OpenTextFile(WSH(0), 1)
Do Until objFile.AtEndOfStream
For i=1 To WSH.Count-1
If objFile.Line = WSH(i) Then
theline=objFile.ReadLine
WScript.Echo theline
End If
Next
objFile.SkipLine
Loop
objFile.Close
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
