ping 테스트 결과를 시간과 같이 파일로 저장하는 스크립트

 

Const ForWriting = 2

strIPAddress = "127.0.0.1"
strResultFile = "C:\TEST\ping_result.txt"

'2시간 기록할 경우, 1초 x 60 x 60 x 2 = 7200000
max_loop = 7200000

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set salObjShell = WScript.CreateObject("Wscript.Shell")

Set objLogFile = objFSO.OpenTextFile(strResultFile , ForWriting, True)
   
Set objExecObject = salObjShell.Exec("%comspec% /c ping " & strIPAddress & " -t")

i = 0

Do Until objExecObject.StdOut.AtEndOfStream
  strResult = objExecObject.StdOut.ReadLine()
  If i > max_loop Then   
   objLogFile.close
   Exit Do
  End If
  DateInfo = Time
  Wscript.echo DateInfo & "  " & strResult
  objLogFile.Write(DateInfo & " : " & strResult )
  objLogFile.writeline
  i = i + 1
  Wscript.Sleep 1000
  
 Loop

+ Recent posts