OC: Windows 2008 R2 Enterprise 64 bit

I can call the tasklist in the console and visually determine. How can I check whether a task is running with the bat code?

  • tasklist /FI "IMAGENAME eq modulename.exe" - and do whatever you need with the result. - Akina
  • Thank. Yes, he now shows only one process. How can I get an unequivocal answer in the if structure? - Predicate

1 answer 1

 @echo off if '%1'=='' goto usage for /F %%a in ('tasklist.exe /FI "IMAGENAME eq %1"') do if %%a==%1 goto exist echo Module %1 not found in processlist. goto done :usage echo USAGE: %0 modulename.ext goto done :exist echo Module %1 is running. :done