/B on EXIT statement in batch files

460 views
Skip to first unread message

rdbossjr

unread,
Mar 24, 2010, 9:49:08 AM3/24/10
to ccnet-user
Hello,

I have recently added the /B to my EXIT statements in my build batch
files. So my Exit statements look like this:

EXIT /B %BUILDFAILED%

where %BUILDFAILED% is set to %ERRORLEVEL% from several process
throughout the batch file.

As a result of adding /B my CCNet projects are now green when they
should be red. This is the only thing that I changed in the batch
files. When I remove the /B from the EXIT statements the builds go
back to being red.

This is not a show stopper but it is annoying because I now cannot
combine these build scripts by calling them from other batch files if
I want those batch files to continue after a failure returns from one
of the build scripts.

Any ideas?

Craig Sutherland

unread,
Mar 25, 2010, 9:41:13 PM3/25/10
to ccnet...@googlegroups.com
Hi David,

I've had a quick look into this, and it appears there is something weird
happening with the batch file execution. Using the following batch file I
can replicate your issue you mentioned:
@ECHO OFF
Whatthe --> This doesn't exist, just need an error level
SET BUILDFAILED = %ERRORLEVEL%
ECHO Doing something
EXIT /B %BUILDFAILED%

With this batch file, CC.NET gets an error code of 0 and thinks everything
is ok.

Now, if I remove the spaces from the SET command, it returns the ERRORLEVEL:
@ECHO OFF
Whatthe --> This doesn't exist, just need an error level
SET BUILDFAILED=%ERRORLEVEL%
ECHO Doing something
EXIT /B %BUILDFAILED%

With this version, CC.NET gets the error code (9009) and fails (as
expected!)

Based on this, I'm guessing you have some spaces in one of your set
statements which means CMD is not setting the value correctly (??)


Craig

Hello,

EXIT /B %BUILDFAILED%

Any ideas?

To unsubscribe from this group, send email to
ccnet-user+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.


rdbossjr

unread,
Mar 27, 2010, 11:06:44 AM3/27/10
to ccnet-user
Craig,

Thanks for looking at it. I will be looking at the set statements
next week. My question is why would it work fine without the /B but
not work with the /B?

I'll let you know what I find.

David

On Mar 25, 9:41 pm, "Craig Sutherland" <cj.sutherl...@xtra.co.nz>
wrote:


> Hi David,
>
> I've had a quick look into this, and it appears there is something weird
> happening with the batch file execution. Using the following batch file I
> can replicate your issue you mentioned:
> @ECHO OFF
> Whatthe --> This doesn't exist, just need an error level
> SET BUILDFAILED = %ERRORLEVEL%
> ECHO Doing something
> EXIT /B %BUILDFAILED%
>
> With this batch file, CC.NET gets an error code of 0 and thinks everything
> is ok.
>
> Now, if I remove the spaces from the SET command, it returns the ERRORLEVEL:
> @ECHO OFF
> Whatthe --> This doesn't exist, just need an error level
> SET BUILDFAILED=%ERRORLEVEL%
> ECHO Doing something
> EXIT /B %BUILDFAILED%
>
> With this version, CC.NET gets the error code (9009) and fails (as
> expected!)
>
> Based on this, I'm guessing you have some spaces in one of your set
> statements which means CMD is not setting the value correctly (??)
>

> Craig-----Original Message-----

David Cameron

unread,
Mar 28, 2010, 1:18:51 AM3/28/10
to ccnet...@googlegroups.com
I just played around at the command-line, and both versions set the correct ERRORLEVEL, at least on Windows7 Pro. It may be an issue in the way the .net framework starts processes? I noticed there isn't any special handling for .bat or .cmd files. Actually, which extension is your batch file using .bat or .cmd?

Dave

rdbossjr

unread,
Apr 6, 2010, 9:20:42 AM4/6/10
to ccnet-user
David,

Thanks for getting back to me. Sorry it took so long to reply as I
have been on vacation for the past week. We are using .bat files.
one thing i noticed is that this only happens when there is more than
one task in the project. Seems like that should not be the case.

Thanks,
David

On Mar 28, 1:18 am, David Cameron <dave...@gmail.com> wrote:
> I just played around at the command-line, and both versions set the correct
> ERRORLEVEL, at least on Windows7 Pro. It may be an issue in the way the .net
> framework starts processes? I noticed there isn't any special handling for
> .bat or .cmd files. Actually, which extension is your batch file using .bat
> or .cmd?
>
> Dave
>

> > ME" as the subject.- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages