title: batch file to check vpn connection when is online/up
body: <p>I need to check the vpn connection when is online/up with a batch file.</p>
  
  <p><strong>Actually i use this code:</strong></p>
  
  <pre><code>PING -n 5 www.google.com|FIND /I "TTL"&gt;NUL
  
  IF NOT "%ERRORLEVEL%"=="1" (
  Echo "Vpn Connection Is Up"
  )
  IF "%ERRORLEVEL%"=="1" (
  Echo "Vpn Connection Is Down"
  )
  </code></pre>
  
  <p>Sometimes the ping give a non response or give a general failure response.</p>
  
  <p>I would like to know that there is a better batch code alternative than the ping command.</p>
  
  <p>I tried this alternative codes but do not recognize vpn when is online/up because the adapter is always in my pc installed.</p>
  
  <p><strong>First Alternative Code:</strong></p>
  
  <pre><code>ipconfig|find /i "VPN" &amp;&amp; GOTO startAPP || GOTO connectVPN
  </code></pre>
  
  <p><strong>Second Alternative Code:</strong></p>
  
  <pre><code>ipconfig|find /i "VPN"
  
  if %errorlevle%==1 goto:connectVPN
  
  echo Starting APP !
  exit/b
  
  :connectVPN
  echo connecting to VPN
  </code></pre>
  
  <p><strong>Third Alternative Code:</strong></p>
  
  <pre><code>:start
  cls
  rasdial | find /I "%vpnname%" &gt; nul
  if errorlevel 1 goto vpndown
  if errorlevel 0 goto vpnup
  </code></pre>
  
  <p>Can You recommend an alternative command to ping to be integrated into my batch code please ?</p>
  
  <p>The alternatives code do not recognize when vpn connection is online, it's recognize if exist the adampter installed in my pc but i need to know when vpn is online/up (ready to go on internet).</p>