title: Batch Script - Ping Address - Write to file if failure
body: <p>I want to ping an IP address every 5 seconds.</p>
  
  <p>If the ping fails, write the date and time to a file.</p>
  
  <p>Here is my non-working attempt...  the loop works as intended, but I can't get it to write to a file if the ping fails.</p>
  
  <pre><code>@ECHO OFF
  set IPADDRESS=172.30.1.36
  set INTERVAL=5
  :PINGINTERVAL
  
  ping %IPADDRESS% -n 1
  if errorlevel 1 echo %date% %time% &gt;&gt; failurelog.txt
  
  timeout %INTERVAL%
  GOTO PINGINTERVAL
  </code></pre>