Loops 循环问题上的VBS
我对vbs中的循环有一个问题 我的脚本每行读取一个文件行并执行一些任务。 我下一步就把错误恢复 发生错误时,脚本继续循环,但使用下一个参数(下一行)。 有没有让脚本继续使用相同参数循环的技巧 这是剧本Loops 循环问题上的VBS,loops,vbscript,Loops,Vbscript,我对vbs中的循环有一个问题 我的脚本每行读取一个文件行并执行一些任务。 我下一步就把错误恢复 发生错误时,脚本继续循环,但使用下一个参数(下一行)。 有没有让脚本继续使用相同参数循环的技巧 这是剧本 on error resume next dim filesys, text, readfile, contents, copy, oNet, objLog set filesys = CreateObject("Scripting.FileSystemObject") set readfile
on error resume next
dim filesys, text, readfile, contents, copy, oNet, objLog
set filesys = CreateObject("Scripting.FileSystemObject")
set readfile = filesys.OpenTextFile("xxxx", 1, false)
set copy = CreateObject("Scripting.FileSystemObject")
set oNet = CreateObject("Wscript.Network")
set objLog = filesys.OpenTextFile("xxxx", 8, true)
do while readfile.AtEndOfStream=false
objLog.WriteLine "0"
contents = readfile.ReadLine
Drive = "Z:"
User = "xxx"
Pass = "xxx"
PER = "FALSE"
Share = "\\" & contents & "\c$\windows\temp"
oNet.MapNetworkDrive Drive, Share, PER, User, Pass
objLog.WriteLine "1"
If Err.Number <> 0 Then
objLog.WriteLine "1.1"
objLog.WriteLine readfile.ReadLine & " ---- ATTENTION: " & Err.Description
' wscript.echo "ATTENTION: " & Err.Description
Err.Clear
End If
copy.CopyFile "Z:\xxx", "xxx" & contents & ".log"
objLog.WriteLine "2"
If Err.Number <> 0 Then
objLog.WriteLine "2.1"
objLog.WriteLine readfile.ReadLine & " ---- ATTENTION: " & Err.Description
' wscript.echo "ATTENTION: " & Err.Description
Err.Clear
End If
objLog.WriteLine "3"
WScript.Sleep 5000
oNet.RemoveNetworkDrive "Z:"
objLog.WriteLine "4"
loop
readfile.close
出错时继续下一步
dim文件系统、文本、读取文件、内容、副本、oNet、objLog
设置filesys=CreateObject(“Scripting.FileSystemObject”)
设置readfile=filesys.OpenTextFile(“xxxx”,1,false)
设置copy=CreateObject(“Scripting.FileSystemObject”)
set oNet=CreateObject(“Wscript.Network”)
设置objLog=filesys.OpenTextFile(“xxxx”,8,true)
读取文件时执行此操作。AtEndOfStream=false
objLog.WriteLine“0”
contents=readfile.ReadLine
Drive=“Z:”
User=“xxx”
Pass=“xxx”
PER=“FALSE”
Share=“\\”&contents&“\c$\windows\temp”
oNet.MapNetworkDrive驱动器,共享,人均,用户,通过
objLog.WriteLine“1”
如果错误号为0,则
objLog.WriteLine“1.1”
objLog.WriteLine readfile.ReadLine&“-----注意:”&错误说明
“wscript.echo”注意:&错误说明
呃,明白了
如果结束
copy.copy文件“Z:\xxx”、“xxx”&内容和“.log”
objLog.WriteLine“2”
如果错误号为0,则
objLog.WriteLine“2.1”
objLog.WriteLine readfile.ReadLine&“-----注意:”&错误说明
“wscript.echo”注意:&错误说明
呃,明白了
如果结束
objLog.WriteLine“3”
WScript.Sleep 5000
一次移除两个驱动器“Z”:
objLog.WriteLine“4”
环
readfile.close
很抱歉,它似乎起作用了
我在日志中对此进行了修改:
objLog.WriteLine readfile.ReadLine & " ---- ATTENTION: " & Err.Description
借
现在日志正常了。它还在继续。很抱歉:)很抱歉,它似乎起作用了 我在日志中对此进行了修改:
objLog.WriteLine readfile.ReadLine & " ---- ATTENTION: " & Err.Description
借
现在日志正常了。它还在继续。很抱歉:)如果出现错误,您的
objLog.WriteLine readfile.ReadLine & " ---- ATTENTION: " & Err.Description
读取/使用源文件中的下一行。使用
objLog.WriteLine contents & " ---- ATTENTION: " & Err.Description
相反。如果出现错误,您的
objLog.WriteLine readfile.ReadLine & " ---- ATTENTION: " & Err.Description
读取/使用源文件中的下一行。使用
objLog.WriteLine contents & " ---- ATTENTION: " & Err.Description
相反