title: Restart server based on ping response
body: <p>I've created this from a mashup of other questions/answers on this site, as well as stuff found at ss64.com</p>
  
  <p>I've hammered it down to what I want, now it's just a crucial missing detail that will make it loop over and over until the connection has been established while <strong>avoiding</strong> constantly starting the server on each cycle.</p>
  
  <p>It's massively over-engineered and horrendously made, but it's basically the culmination of all I've learned and just working it out in a way I can understand.</p>
  
  <p>The main issue with it right now is if it's less than 100% packet loss, it will start the server, even if it's 80% packet loss which is too high for anything to connect or function on.</p>
  
  <p>I'm looking for that crucial command to ensure the server will only start if there is 100% connection and also make sure it <strong>wont</strong> keep starting the server if there is 100% connection in a continued loop (which has happened far too many times, 50 instances of a server running really is a PC killer).</p>
  
  <p>Here is what I have (don't laugh too hard).</p>
  
  <pre><code>@echo off 
  title Server Restart
  color 0A
  cls
  :start
  Cls
  set ip=xxx.xx.xxx.xx
  
  :ping
  ping %ip% -n 5 || goto PingFail
  timeout /t 8
  cls
  echo Ping was Successful to %ip% at %date% %time%
  timeout /t 10
  ping %ip% -n 5 -w 5000 &amp;&amp; goto start
  echo Moving To PingFail...
  goto PingFail
  
  
  :Starting
  Echo Connection Established... Starting server
  **Start Server.bat**
  Echo Start Successful
  goto start
  
  
  :PingFail
  cls
  Echo Connection Has Failed.. looping.
  timeout /t 3
  goto Pingloop
  
  
  :Pingloop
  echo PINGLOOPING
  ping %ip% -n 5 || goto Pingloop
  timeout /t 15
  goto Starting
  </code></pre>