How can I tell if a specific process is running using a batch file?
For example, How can I tell if notepad.exe
is running?
How can I tell if a specific process is running using a batch file?
For example, How can I tell if notepad.exe
is running?
Consider the following proposal (run in your batch file):
tasklist | findstr /R ^notepad.exe
Simple, but works!
tasklist /?
Will show you a lot of great options for filtering and managing your output.
findstr /?
Will also show you a great set of options to search and filter the output of tasklist
I hope this helps.
Powershell has an in-built function. Get-Process Get-Process will tell you about all the processes. If you wish to filter with a particular one then use :
Get-Process|?{$_.Name -eq 'Notepad'}
Screenshots are for reference:
Type Powershell in cmd prompt:
Run the above query. If the notepad is running. It will show you:
Hope it helps...
You can do something like this in batch file :
This one is inspired from Check if a process is running or not?
@echo off
Title Check for running process . . .
mode con cols=50 lines=3
set "MyProcess=notepad.exe"
set delay=5
:Main
cls
Tasklist /FI "IMAGENAME eq %MyProcess%" | find /I "%MyProcess%">nul && (
echo( & Color 9A
echo PROCESS "%MyProcess%" IS RUNNING !
)||(
echo( & Color 4C
echo PROCESS "%MyProcess%" IS NOT RUNNING !
)
Timeout /T %delay% /nobreak>nul
Goto Main