DOS - result of command used in if statement

Dell / OPTIPLEX 755
May 28, 2009 at 04:49:47
Specs: Microsoft Windows XP Professional, 2.327 GHz / 2013 MB
hello friends, i am hoping someone here can offer me some help.

I have the following command.

tasklist /FI "IMAGENAME eq outlook.exe" /FO CSV > C:\temp\search.log

This creates a file called search.log in C:\temp.

Now I have this command that echos 1 if outlook is running and 0 if it isnt.

findstr "OUTLOOK" C:\temp\search.log | FIND /C "OUTLOOK"

basically if it echos 0 i want it to goto the end, something like this

If result of command is 0 goto end
else kill outlook

you see what i am getting at?

Any help would be much appreciated.


See More: DOS - result of command used in if statement

Report •

May 28, 2009 at 05:29:07
This might be of use?

@echo off
tasklist 2>nul | find "OUTLOOK.EXE" >nul || goto :next
echo Outlook running
echo Outlook not found

Report •

May 28, 2009 at 07:44:14
More simply:

find "string" < myfile > nul
goto :%errorlevel%

echo got it


If at first you don't succeed, you're about average.


Report •

May 29, 2009 at 00:22:28
haha thanks fellas, I was going totally over the top!

Report •

Related Solutions

Ask Question