You are not logged in.

#1 20 Oct 2014 02:20

smurff289
New Member
Registered: 20 Oct 2014
Posts: 2

Errorlevel and Checking Running Commands

I am wanting to write a script that adjusts based on the services running.  I want to check for a file running in my batch file and than act accordingly.

tasklist /fi "imagename eq notepad.exe"

Is there a way to read the output and use that to change what happens next?
Using Errorlevel always returns a value of 0.

Example...
tasklist /fi "imagename eq notepad.exe"
if notepad is running - echo I am running!
if notepad isnt running - echo I am not running!

Offline

#2 20 Oct 2014 04:19

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Errorlevel and Checking Running Commands

use a find filter to locate notepad.exe and then find.exe will set the errorlevel.

Offline

#3 20 Oct 2014 04:28

smurff289
New Member
Registered: 20 Oct 2014
Posts: 2

Re: Errorlevel and Checking Running Commands

tasklist | find "notepad.exe"

Great idea! Thanks.

Offline

#4 16 Dec 2014 04:34

chinkitkit
Member
Registered: 16 Dec 2014
Posts: 14

Re: Errorlevel and Checking Running Commands

Hi, smurff289.

it seems like you understand the concept of errorlevel.

can you explain to me, what is errorlevel ?

what is returning value to 0 and 1 ?

i don't get that part.

thank you.


Detour in life always surprise people.

Offline

Board footer

Powered by