title: Batch delayed expansion not working
body: <p>Ok, I'm getting crazy and I don't know what else to do, I've tried several things and nothing is working.</p>
  
  <p>Look at this sample code (test.cmd):</p>
  
  <pre><code>setlocal enabledelayedexpansion enableextensions
  set VAR=before
  if "%VAR%" == "before" (
      set VAR=after;
      if "%VAR%" == "after" @echo If you see this, it worked
  )
  </code></pre>
  
  <p>This is the generated output:</p>
  
  <pre><code>D:\&gt;ver
  
  Microsoft Windows [Version 6.1.7600]
  
  D:\&gt;test.cmd
  
  D:\&gt;setlocal enabledelayedexpansion enableextensions
  
  D:\&gt;set VAR=before
  
  D:\&gt;if "before" == "before" (
  set VAR=after;
   if "before" == "after"
  )
  
  D:\&gt;
  </code></pre>
  
  <p>Am I doing something wrong?</p>
  
  <p>This is just a test, the code I need uses variables too and needs delayed expansion, but it this simple test doesn't work the other wont work either (I've tried, I ended up with a simple example to test if it worked).</p>
  
  <p>EDIT: New code and output:</p>
  
  <p>test.cmd:</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion enableextensions
  set VAR=before
  if "%VAR%" == "before" (
     set VAR=after;
     if "!VAR!" == "after" (
        echo It worked.
     ) else (
        echo It didn't work.
     )
  )
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>D:\&gt;test.cmd
  It didn't work.
  
  D:\&gt;
  </code></pre>