General Question

XOIIO's avatar

Check if a process is running from a batch file?

Asked by XOIIO (18328points) January 1st, 2011
2 responses
“Great Question” (0points)

I need a command simmilar to “IF EXIST” to check if a process, such as wmplayer.exe is running. Something like this.

if exist wmplayer.exe (echo proccess running) else (echo proccess not running

Can you think of anything?

Topics: ,
Observing members: 0
Composing members: 0

Answers

XOIIO's avatar

Well, I have this bit of code

IF ”%notepad.exe%”==”” (echo The process is not running) ELSE (echo the program is running)

With it set up like this it always says the process is not running

IF ”%notepad.exe”==”” (echo The process is not running) ELSE (echo the program is running)

With this it aways it running.

Any ideas on how to get it to work? I know I’m really close.

XOIIO's avatar

I got this to work.

@echo off
tasklist /FI “IMAGENAME eq wmplayer.exe” | find /I “wmplayer.exe”
IF ERRORLEVEL 2 ECHO Windows Media Player is running
IF ERRORLEVEL 1 ECHO Windows Media Player is not running
pause>nul

But it shows this when the process is running.

wmplayer.exe 13788 Console 1 20,300 K

I tried adding >nul to the tasklist line but then it didn’t show anything when the process was running.

Answer this question

Login

or

Join

to answer.

Mobile | Desktop


Send Feedback   

`