title: Put reg query output into a variable
body: <p>I am a bit unexperienced with CMD and hope someone here can help me.</p>
  
  <p>In one old installation script of mine I now need to check if .NET 3.5 is installed, and then either install the 3.5 package or move on with the script depending on the result.</p>
  
  <p>Now I have some trouble trying to check for the installed version in my Script.</p>
  
  <p>I use this reg query to look for the installed version:</p>
  
  <pre><code>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP" | Find "3.5"
  </code></pre>
  
  <p>which outputs a single line, if 3.5 is installed, or nothing if it isn't:</p>
  
  <pre><code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5
  </code></pre>
  
  <p>Now my idea was, to create a variable and fill the value with the output seen above.</p>
  
  <p>Unfortunately something like:</p>
  
  <pre><code>set DNFound=reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP" | Find "3.5"
  if not exist %DNFound%
  (
   install framework
  )
  </code></pre>
  
  <p>doesn't work, because the output wont get saved in the variable.</p>
  
  <p>I have researched a bit and seen people go for a loop in this format to get single values from the reg query output into a variable (sample code):</p>
  
  <pre><code> for /f "tokens=3" %%x in ('reg query HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile /v EnableFirewall') do set FWSTATUS=%%x
  </code></pre>
  
  <p>However I get a syntax error when I try to do the same, because of the <code>| Find "3.5"</code>  part in my reg query.</p>