title: I want to save the result of the command as a variable in window batch
body: <p>I try use the <code>for /f</code> statement to get the command result like <code>error : file not found</code> but this code <code>%_result% return null</code></p>
  
  <p>How do I get the result of the command?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>SET CML=forfiles /p %BAKPATH% /M *.zip /D -10 /C "CMD /C del @file"
  
  FOR /F "tokens=* USEBACKQ" %%F IN (
  '%CML%'
  ) DO (
  SET _result=%%F
  )
  
  echo result = %_result%
  </code></pre>