title: How do I store output in a variable from Windows "where" command, in a batch file?
body: <p>I am using the "where" command from a Windows batch file to find the location of my java installation for a script</p>
  
  <p>so normally from a commandline,</p>
  
  <pre><code>C:\Users\user&gt;where java
  C:\ProgramData\Oracle\Java\javapath\java.exe
  </code></pre>
  
  <p>Now I need to be able to get the output path of "where" in a variable for later use in my batch file, how do I do that?</p>
  
  <p>I tried something like,</p>
  
  <pre><code>@echo off
  cls
  set var=1
  setlocal enableextensions
  for /F "tokens=* USEBACKQ" %%F in ('where java') do (
      set var=%%F
  )
  echo %var%
  endlocal
  pause
  </code></pre>
  
  <p>but it doesn't work.</p>