Computing.Net > Forums > Disk Operating System > IF command-Batch file help needed!

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

IF command-Batch file help needed!

Reply to Message Icon

Original Message
Name: Jake2211
Date: April 17, 2003 at 16:55:17 Pacific
Subject: IF command-Batch file help needed!
OS: 2000
CPU/Ram: 1.6
Comment:

Hello,

I have batch file that starts a small exe file to connect to a device through COM 1 to send some data. Here's where I need some help. The program does not return error codes, but I need to use an IF, GOTO statement to compare 2 results and go to different parts of the batch file based on those results.

The output text is either this for failure:
(E) Can't communicate with emmi box

or this for success:
Flexing EMMI Box to power up in EMMI Mode

If the first event happens, I want to go to the line :fail. If the second event happens, I want to go to the line :success.

I have tried several IF statements, and none of them can recognize the different events, and go to the proper line. If anyone can help, I would really appreciate it.


Report Offensive Message For Removal


Response Number 1
Name: Secret_Doom
Date: April 17, 2003 at 21:16:14 Pacific
Reply: (edit)

This sample should show you a solution:

prog.exe parameters |FIND "(E)"> nul
if errorlevel=1 goto success
goto error

Basically, we search for the string "(E)" on the output from prog.exe, using FIND.exe. It will return an errorlevel 0 if it string is found, and 1 if not.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software