title: Store curl command output in a variable in batch script
body: <p>I tried many examples online, but was not able to make it work. I am new to this so please forgive my primitive question.</p>
  <p>say I have this:</p>
  <pre><code>curl &quot;www.google.com&quot; -o /dev/null -s -w &quot;%{http_code}\n&quot;
  </code></pre>
  <p>when running this in a cmd window, it returns the response code.</p>
  <pre><code>200
  </code></pre>
  <p>which is as expected.</p>
  <p>I would like to do something like this in a batch script, but also use the output of the curl command to set a variable.
  All examples I found online propose:</p>
  <pre><code>set res = $(curl &quot;www.google.com&quot; -o /dev/null -s -w &quot;%{http_code}\n&quot;)
  echo %res%
  pause
  </code></pre>
  <p>or like this</p>
  <pre><code>FOR /F &quot;tokens=* USEBACKQ&quot; %%F IN (`curl www.google.com -o /dev/null -s -w &quot;%{http_code}\n&quot;`) DO ( SET var=%%F ) 
  ECHO %var%
  pause 
  </code></pre>
  <p>both did not work, my batch script closes immediately.</p>
  <p>Any feedback or help is highly appreciated
  thank you.</p>