'-------------------Determining PING Status of Multiple Computers--------------------------
Set objExcel = CreateObject("excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "ComputerName"
objExcel.Cells(1, 2).Value = "Ping Status"
Set objFso = CreateObject("Scripting.FileSystemObject")
Set Inputtxt = objfso.OpenTextFile("List.Txt")
Do While Not (Inputtxt.atEndOfStream)
HostName = Inputtxt.ReadLine
Set WshShell = WScript.CreateObject("WScript.Shell")
Ping = WshShell.Run("ping -n 1 " & HostName, 0, True)
objExcel.Cells(intRow, 1).Value = HostName
Select Case Ping
Case 0 objExcel.Cells(intRow, 2).Value = "On Line"
objExcel.Cells(intRow, 2).Interior.ColorIndex = 35
Case 1 objExcel.Cells(intRow, 2).Value = "Off Line"
objExcel.Cells(intRow, 2).Interior.ColorIndex = 19
End Select
intRow = intRow + 1
Loop
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 40
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Wscript.echo "PING COMPLETED"
No comments:
Post a Comment