title: Batch ping a list of computer names and write the results to file
body: <p>The code below will write the computer name and ip address to file, but I would like it to also write the name of the computers it cannot ping with a fail next to it. I have no idea how I would modify the batch file to do this.</p>
  
  <pre><code>@echo off
  
  Echo Pinging list...
  
  set ComputerList=list.txt
  
  Echo Computername,IP Address&gt;Final.csv
  setlocal enabledelayedexpansion
  
  for /f "usebackq tokens=*" %%A in ("%ComputerList%") do (
  for /f "tokens=3" %%B in ('ping -n 1 -l 1 %%A ^|findstr Reply') do (
  set IPadd=%%B
  echo %%A,!IPadd:~0, -1!&gt;&gt;Results.csv
  ))
  
  pause
  </code></pre>