acidrain
Executive Member
Hi Guys,
I've been looking online for a script that could ping selected hostnames from a txt file and export the results (online/offline). I've come across a VBS script that does exactly this, and exports to an xls spreadsheet. The problem is that it open up the spreadsheet with all the values but doesn't save it.
I would like to automate this script for every 10min or so, so would like to know what i need to add in order for the script to save the file.
Additionally is it possible that the xls sheet could be viewed instead of downloaded when navigating to the file on my webserver?
Code below:
Thanks in advance
I've been looking online for a script that could ping selected hostnames from a txt file and export the results (online/offline). I've come across a VBS script that does exactly this, and exports to an xls spreadsheet. The problem is that it open up the spreadsheet with all the values but doesn't save it.
I would like to automate this script for every 10min or so, so would like to know what i need to add in order for the script to save the file.
Additionally is it possible that the xls sheet could be viewed instead of downloaded when navigating to the file on my webserver?
Code below:
Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "Results"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
HostName = InputFile.ReadLine
Set WshShell = WScript.CreateObject("WScript.Shell")
Ping = WshShell.Run("ping -n 1 " & HostName, 0, True)
objExcel.Cells(intRow, 1).Value = UCase(HostName)
Select Case Ping
Case 0 objExcel.Cells(intRow, 2).Value = "On Line"
Case 1 objExcel.Cells(intRow, 2).Value = "Off Line"
End Select
If objExcel.Cells(intRow, 2).Value = "Off Line" Then
objExcel.Cells(intRow, 2).Font.ColorIndex = 3
Else
objExcel.Cells(intRow, 2).Font.ColorIndex = 4
End If
intRow = intRow + 1
Loop
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
Thanks in advance