title: In Windows cmd, how do I prompt for user input and use the result in another command?
body: <p>I have a Windows .bat file which I would like to accept user input and then use the results of that input as part of the call to additional commands.</p>
  
  <p>For example, I'd like to accept a process ID from the user, and then run jstack against that ID, putting the results of the jstack call into a file. However, when I try this, it doesn't work. </p>
  
  <p>Here's my sample bat file contents:</p>
  
  <pre><code>@echo off
  set /p id=Enter ID: 
  echo %id%
  jstack &gt; jstack.txt
  </code></pre>
  
  <p>and here's what shows up in jstack.txt:</p>
  
  <pre>
  Enter ID: Terminate batch job (Y/N)? 
  </pre>