title: VB script to get IP address from Ping command
body: <p>I'm trying to write a script to show every server ipaddress that I put into a text file. I've been looking online and came across the script below. What I need is instead of it showing 'online' I need it show show the actual IP address of each server in the text file. I've been looking for an answer to this for a while now, I've pretty new to vbs so I'm sorry if the script below is wrong or simple. This does open an excel doc which I'm pretty happy with. </p>
  
  <pre><code>Set objExcel = CreateObject("Excel.Application")
  objExcel.Visible = True
  objExcel.Workbooks.Add
  intRow = 2
  
  objExcel.Cells(1, 1).Value = "Server Name"
  objExcel.Cells(1, 2).Value = "IP Address"
  
  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 " &amp; 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, 2).Value = "Off Line"
  End Select
  
  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 
  </code></pre>