user541686
user541686

Reputation: 210515

Batch File: Return to caller?

What is the equivalent of the return statement for a batch file subroutine?

Upvotes: 38

Views: 40964

Answers (3)

GaryNg
GaryNg

Reputation: 1123

Goto :Eof

Exit

Goto :Eof usually use in call command such as:

@echo off
call :Hi
pause&exit
:hi
echo Hello!
goto :eof 

Upvotes: 3

Aacini
Aacini

Reputation: 67216

I think that it is:

exit /b [exitCode]

Not just because it is more understandeable to use, but also because exit /b (and just exit also) may return an exitCode (ERRORLEVEL) value to the caller program.

In my modest opinion, goto :eof is a strange patch that should not be used...

Upvotes: 27

Greg Hewgill
Greg Hewgill

Reputation: 993223

It is:

goto :eof

This is understandably unusual for somebody accustomed to normal programming languages.

I found this info here.

Upvotes: 37

Related Questions