title: How to make a batch file react differently based on the success percent of a ping command?
body: <p>I'm trying to figure out a way to get a batch file to respond differently based on the results of a series of 4 pings. If the pings have a 0% loss, a web page should open. If the command returns a loss % higher than 0, then a goto command should initiate.</p>
  
  <p>The things I've attempted already are changing the "else" in my code to if "%errorlevel%"=="4" or if "%errorlevel%"=="100"</p>
  
  <pre><code>:login3
  cls
  echo.
  echo  Login information cleared!
  echo  Press any key to confirm internet connection.
  pause &gt; nul
  ping 8.8.8.8
  if "%errorlevel%"=="0" start "" https://stackoverflow.com
  else goto :login_fail
  
  cls
  echo.
  echo  test
  echo  if you got connected to the website, then you should end up here.
  pause
  exit
  
  :login_fail
  cls
  color 0c
  echo.
  echo  Login failed. Try again later.
  pause &gt; nul
  </code></pre>
  
  <p>If I have an internet connection or not, I will always get sent to the test message, and the website will attempt to open.</p>