Capturing return value in batch scr

Score
0
Vote Up
August 3, 2006 at 14:28:00 Pacific
Specs: Win XP Professional, Pentium

For /F "tokens=1" %%i in (TempJobNames.txt) do (
Executing a Command to call other application
IF %ERRORLEVEL%==0 ECHO Success
IF NOT %ERRORLEVEL%==0 ECHO Failed)


Reply ↓  Report •


#1
Vote Down
Score
0
Vote Up
August 3, 2006 at 14:31:39 Pacific

Sorry. Forgot to add the question...

This code is not working. Errorlevel always returns 0 even if it's failure...

Am I missing something here ?

Thanks


Reply ↓  Report •

#2
Vote Down
Score
0
Vote Up
August 4, 2006 at 02:38:18 Pacific

"Am I missing something here ?"

I ask myself that often.

If the executable doesn't set errorlevel, there's probably not much you can do about it. If it writes any result to stdout, you could work with that.

BTW you can skip the % and ==

if errorlevel 0 echo blabla


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

M2



Reply ↓  Report •

#3
Vote Down
Score
0
Vote Up
August 4, 2006 at 04:55:23 Pacific

Does the command only behave like this in the for loop - or always?

uli



Reply ↓  Report •

#4
Vote Down
Score
0
Vote Up
August 4, 2006 at 07:34:27 Pacific

It always behaves like this...Inside loop or not it always returns 0...How can I make the executable set errorlevels ?

Thanks


Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« ASP.NET 2.0 / VB.NET SetF... Dos script run in the bac... »

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

Ask the Community!
Describe your Problem
Example: Hard Drive Not Detected on My PC