У меня проблема с петлей в vbsVBS on loop issue
Мой скрипт читает строку файла в строке и выполняет некоторые задачи. Я включил ошибку в следующем.
При возникновении ошибки сценарий продолжает цикл BUT со следующим аргументом (следующая строка). Есть ли советы по созданию цикла продолжения скрипта с тем же аргументом?
Вот сценарий.
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