title: IF statement causing batch file to crash
body: <p>G'Day, I am creating a program that tells you if your connected to the internet or not and one crucial part of that program is the following if statement,</p>
  
  <pre><code>ping google.com &gt;nul
  
  if %errorlevel% NEQ 0 goto no
  rem "no" is not showed in this code example
  if %errorlevel% EQU 0 goto yes
  
  :yes
  if %a% EQU 1 (
      goto Begin
  ) else (
      cls
      color a
      echo Connected
      set a=1
  )
  </code></pre>
  
  <p>In this context the variable "a" defines connectivity,</p>
  
  <p>For example this piece of code loops so if "a" is equal to "1" we know that we are already connected and this code is not necessary so we should loop back to the ping command. When "a" is "0" we know that we were previously not connected to the internet. </p>
  
  <p>That might be hard to swallow so if you have a question about it ask it below as I can't think of a better explanation</p>
  
  <p>That aside this (as I said in the title) keeps crashing as a batch file (exiting unexpectedly.) I cannot find an answer to this question and it is driving me nuts. (Link to all the code <a href="https://docs.google.com/document/d/1-bfAlD2hU8cmLvMorEVzppjqxws80DW5Xnn6jSYDmvY/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/document/d/1-bfAlD2hU8cmLvMorEVzppjqxws80DW5Xnn6jSYDmvY/edit?usp=sharing</a> )</p>
  
  <p>Thanks Much
  -R</p>