Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

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

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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.


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:

  • /fi “”:  This argument is used to define a filter of apps that are required to be found out. Since we want to check the process hence, it’s the *.exe name
  • /fo csv:  This argument is used to opt for the output format. Note that csv is necessary, this is because the executable name may be truncated (by default) when it is too long. Because of this, it will not match by find later.
  • find /I: It means that the matching is case-insensitive matching.
  • ECHO OFF, PAUSE: This command is used to prompt the user and waits until input is given.
  • VLC.exe: In this example, we are using the VLC media player as a process.
  • if “%ERRORLEVEL%”==”0”  (echo Process / Application is running): If the process is running then print the same to the console.
  • else (echo Process / Application is not running): The else print process is not running to the console.

# process.bat


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)



My Personal Notes arrow_drop_up
Last Updated : 21 Feb, 2022
Like Article
Save Article
Similar Reads
Related Tutorials