title: Find the version of a installed program from batch file
body: <p>We have a batch file that installs several programs as part of the developers setup. This is ran periodically when we get new versions of used components. So it would be nice only to install if the versions are different.</p>
  
  <p>At the command prompt I can run this and get back the version installed:</p>
  
  <pre><code>wmic datafile where name='C:\\Program Files (x86)\\Common Files\\Company\\Product\\Version12\\Product.exe' get version /format:list
  </code></pre>
  
  <p>Which gives the output <code>Version=12.1.369.0</code>.</p>
  
  <p>However when I put this into a batch file like this and try to extract the version:</p>
  
  <pre><code>echo off
  FOR /F "tokens=2 delims==" %%I in ('"wmic datafile where^(name^="C:\\Program Files (x86)\\Common Files\\Company\\Product\\Version12\\Product.exe" get version /format:list"') DO (SET "RESULT=%%I")
  ECHO %RESULT%
  </code></pre>
  
  <p>I get the response <code>\\Common was unexpected at this time.</code></p>
  
  <p>Some parts may be redundant as I've been trying stuff off the 'Net to correct this.</p>
  
  <p>What have I missed?</p>