안녕하세요 여러분, 내 vbs 스크립트에 문제가 있습니다. 내 스크립트는 텍스트 파일을 열어 그것을 읽고 일부 항목을 제거합니다. 원본 파일의 마지막 줄이 대상 파일에 약 30 번 작성되기 때문에 스크립트에서 Somwhere가 오류가 발생해야합니다. 내 코드에서 오류를 발견하지 못했을 수도 있습니다. 예 나는 큰 코드를 게시하지 말아야 알고 parts.Here 내 코드입니다 :이 늘 문제를 해결하지만 만약 조건을 줄일 수 있지만내 스크립트에서 오류를 찾을 수 없습니다.
separator = " "
x = 0
strRawPath = "C:\xampp_neu\xampp\htdocs\tc_backup\stasknoheader.txt"
strRawPathW = "C:\xampp_neu\xampp\htdocs\tc_backup\stask.txt"
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
Set fsw = CreateObject("Scripting.FileSystemObject")
' 2 = ForWriting
Set f = fs.OpenTextFile(strRawPath,1)
Set w = fsw.OpenTextFile(strRawPathW,2)
Do While f.AtEndOfStream <> True
x = x+1
'Anlegen des Arrays
ReDim Preserve myArray(x)
strLine = f.Readline
'Speichern in Array
myArray(x) = strLine
'Loop so that lines that contains Microsoft or TaskName are not written
If InStr(strLine, "Microsoft") = 0 Then
If InStr(strLine, "TaskName") = 0 Then
If InStr(strLine, "Restart System") = 0 Then
If InStr(strLine, "Scheduler-HSM-mig-TC11TDrive") = 0 Then
strNewLine = strNewLine & strLine & vbCrLf
'Replace blank with " AM, "
strNewLine =(Replace(strLine," ",separator,1,2))
'Removes \ from TaskName
strNewLine =(Replace(strNewLine,"\","",1,1))
'WScript.Echo strNewLine
End If
End If
End If
End If
w.write strNewLine & VbCrLf
'WScript.Echo strNewLine
Loop
f.Close
w.Close
그래서이 줄을 말하면 w.write strNewLine & VbCrLf가 30 번 기록됩니까? – DevelopmentIsMyPassion
@AshReva 소스 파일의 마지막 줄을 쓰는 dest 파일에 쓰는 경우에만 30 번 쓰고 다른 줄은 모두 한 번 쓰게됩니다 – Alesfatalis
줄의 나머지는 If 조건 안에 있고 너 밖에있는 유일한 줄이 있기 때문에 조건 일 경우. 루프는 루프가 실행될 때까지 실행됩니다. f.AtEndOfStream에서 카운트 또는 무언가를 얻었습니까? – DevelopmentIsMyPassion