title: Get commandline of process and taskkill
body: <p>I need some help here.</p>
  
  <p>I am currently trying to kill any process that isn't in a whitelist (command line) like so, however it is not working.:</p>
  
  <pre><code>@echo off
  setlocal
  
  set "whitelist=DcomLaunch RPCSS LocalServiceNetworkRestricted netsvcs LocalService LocalSystemNetworkRestricted NetworkService LocalServiceAndNoImpersonation taskhostex cmd dwm conhost services smss SearchIndexer Isass Explorer csrss conhost cftmon"
  
  for /f "tokens=2 delims=," %%I in (
  'wmic process get executablepath^,status /format:csv ^| find "\"'
  ) do (
  set "proc=%%~I"
  setlocal enabledelayedexpansion 
  set /p "=%%~I: "&lt;NUL
  wmic path win32_process get CommandLine | findstr /i "%whitelist%" &gt;NUL &amp;&amp; (
      echo OK
  ) || (
      echo UNACCEPTABLE!
      taskkill /im "%%~nxI" /f
  )
  endlocal
  )
  </code></pre>