title: How to output continously CPU usage of a specific process into a text file?
body: <p>I am planning to write a PowerShell or batch script which writes the CPU usage of a process continuously into a text file. I am new to Windows, have worked on bash before. I am struggling with below batch script.</p>
  
  <p>Can someone help me with it?</p>
  
  <p>I even checked Sysinternals' <code>PsList</code>, however not sure which one to use.</p>
  
  <pre><code>for /f "skip=2 tokens=2 delims=," %%c in ('typeperf "\Process(java.exe)\%% Processor Time" -sc 1') do (
      set cpu_usage=%%~c
      goto :break
  )
  </code></pre>