title: DOS batch: SET variable and ECHO it within (...) block
body: <p>I had a problem with <code>set</code> not working in a batch file; it took a while to distil the problem; at first I thought it was to do with subroutine calls...</p>
  
  <p>The script</p>
  
  <pre><code>@echo off
  setlocal
  set a=aaa
  echo a = "%a%"
  (
  set b=bbb
  echo b = "%b%"
  )
  </code></pre>
  
  <p>produces the output</p>
  
  <pre><code>a = "aaa"
  b = ""
  </code></pre>
  
  <p>whereas I'd expect</p>
  
  <pre><code>a = "aaa"
  b = "bbb"
  </code></pre>
  
  <p>Why is this please? Is it a bug in DOS? Perhaps there's something about the <code>(...)</code> command grouping syntax that I'm unaware of.</p>
  
  <p>Thanks.</p>