title: Variable Scope - access variable outside for-loop - Windows Batch
body: <p>How can I access the variable !processid! outside the for loop?
  I can't get it to work</p>
  
  <pre><code>@ECHO OFF
  SETLOCAL ENABLEDELAYEDEXPANSION
  SETLOCAL 
  
  FOR /F "tokens=* skip=1 delims=" %%a in ('"wmic PROCESS WHERE "CommandLine LIKE '%%scanforstring%%' AND NOT CommandLine LIKE '%%WMIC%%'" get processid"') do (    
  set prozessid=%%a
  echo !prozessid!
  )
  
  echo !prozessid!
  
  PAUSE
  endlocal
  </code></pre>