title: Batch Files third "If NOT" statement not reached
body: <p>Hello stackoverflow community,</p>
  
  <p>I am writing a batch file to do some automatic computer maintenance and have included several antivirus applications. For some reason, the third "if not" statement is never reached.</p>
  
  <pre><code>:AV
  REM MSE
  if not '%MSE%'=='' (
  Echo Scanning for viruses using Microsoft Security Essentials.
  Echo.
  %MSE% -Scan -ScanType 1
  Echo.
  GOTO Defrag
  )
  
  REM AVG
  if not '%AVG%'=='' (
  Echo Scanning for viruses using AVG.
  Echo.
  %AVG% /COMP /QT /TRASH
  Echo.
  GOTO Defrag
  )
  
  REM NOD32
  if not '%NOD32%'==''(
  Echo Scanning for viruses using NOD32.
  Echo.
  if '%NOD32%'=='' GOTO NOD32NotFound
  %NOD32% /aind /auto /log-file="%userprofile%\Desktop\Scan_Results.txt"
  Echo.
  GOTO Defrag
  )
  
  REM If all else fails...
  GOTO AVNotFound
  </code></pre>
  
  <p>Currently, there are three blocks of codes, one for each antivirus program. Each block of code is executed only when the variable %AVG% %MSE% or %NOD32% is not empty, meaning they point to a valid file. I assign the variables using the code:</p>
  
  <pre><code>if exist "%programfiles(x86)%\AVG\AVG2012\avgscana.exe" set AVG="%programfiles(x86)%\AVG\AVG2012\avgscana.exe"
  </code></pre>
  
  <p>All three blocks of code works perfectly, nothing is wrong with the coding. The problem is that whatever the third block is, it never executes. So in the current example, the blocks of code go in the order of MSE, AVG, and NOD32. NOD32's block of code does not execute because it's the third block. Conversely, if I cut and paste the blocks into another order with AVG's block of code being the third block, it would not execute.</p>
  
  <p>Any ideas?</p>
  
  <p>Any suggestions?</p>
  
  <p>Edited for clarification.</p>