Open In App

Batch Script – How to check if a process is running via a Batch Script

Given a process or application (.exe) file, the task is to create a batch script that checks whether the process is running or not and output the same.

Example:



In this example, we have created a batch script by the name process.bat. We can easily check whether a process is currently running or not using the tasklist toolkit. Tasklist allows us to check for current processes. Each of the statements of the below script is discussed below:

# process.bat



ECHO OFF

tasklist /fi “ImageName eq VLC.exe” /fo csv 2>NUL | find /I “VLC.exe”>NUL

if “%ERRORLEVEL%”==”0”  (echo Process / Application is running) else (echo Process / Application is not running)

PAUSE

Output:

Article Tags :