我试图修改一个现有的VBscript,从我的不同站点从服务器名称从文本文件中拉出来,然后ping它们,服务器都被网站分组在一起他们位于。该脚本会在Excel页面中显示服务器是联机还是脱机。这一切都可以正常工作,但脚本也尝试ping站点的名称。这里的目标是主要通过在excel文件中显示网站名称来清理我的结果,但不会被ping通。 这里是我当前的VBScriptVBS ping一组服务器但ping不通群名
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 = "On Line"
objExcel.Cells(1, 3).Value = "Off Line"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("servers.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 = HostName
Select Case Ping
Case 0 objExcel.Cells(intRow, 2).Value = "On Line"
Case 1 objExcel.Cells(intRow, 3).Value = "Off Line"
End Select
intRow = intRow + 1
Loop
objExcel.Range("A1:B1:C1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
这里是文本文件的副本。
DISTRICT OFFICE
Server A
Server B
LAB
Server LA
School 1
Server 1A
Server 1B
School 2
Server 2A
Server 2B
School 3
Server 3A
Server 3B
Server 3c
你的'servers.txt'文件在哪里?那包括网站吗? – Marc
我编辑了问题以包含文本文档的副本。这是否有帮助? –
想要ping的所有行条目都以“School”开始? – Sorceri