Computing.Net > Forums > Disk Operating System > Exit script in Batch command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Exit script in Batch command

Reply to Message Icon

Name: zaks
Date: November 21, 2007 at 04:34:03 Pacific
OS: Win 2003
CPU/Ram: 1
Comment:

In batch script I'm writing a for loop which should exit when there is a return value of 0 but the function is still continuing though exit function is executed.

Can you please help?

For %%a in (1 2 3) do (
SET WG=%%a
CALL :CheckCondition
)

SET /A rc=99
GOTO :EXITNOW

:CheckCondition
.....
SET retcode=%errorlevel%
IF %retcode%==0 (
GOTO :EXITNOW
)
GOTO :EOF

:EXITNOW
_exit %rc%




Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: November 21, 2007 at 04:46:18 Pacific
Reply:

Replace

_exit %rc%

with

exit %rc%


0

Response Number 2
Name: Mechanix2Go
Date: November 21, 2007 at 06:50:53 Pacific
Reply:

SETting a var = errorlevel then testing the var seems like lost motion. May as well just test errorlevel.



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

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


SET from a file? Boot from a mp3 player?



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


Sponsored links

Ads by Google


Results for: Exit script in Batch command

dos color in batch file? www.computing.net/answers/dos/dos-color-in-batch-file/9720.html

Dos Batch command to re-boot a PC. www.computing.net/answers/dos/dos-batch-command-to-reboot-a-pc/3402.html

How do iput wait or delays in batch files ? www.computing.net/answers/dos/-how-do-iput-wait-or-delays-in-batch-files-/4724.html