title: store SID in a variable
body: <p>I need a way to store the current user's SID in a variable, I tried a lot of variants of: </p>
  
  <pre><code>setlocal enableextensions 
  for /f "tokens=*" %%a in ( 
  '"wmic path win32_useraccount where name='%UserName%' get sid"'
  ) do ( 
  if not "%%a"==""
  set myvar=%%a
  echo/%%myvar%%=%myvar% 
  pause 
  endlocal 
  </code></pre>
  
  <p>None are working.</p>
  
  <p><code>wmic path win32_useraccount where name='%UserName%' get sid</code> 
  should be returning 3 lines, and I need the second one stored in a variable.</p>
  
  <p>Can someone fix my script?</p>
  
  <p><em>Edit</em>: I am using a .cmd file.</p>