#1 02 May 2019 08:45

PiotrMP006
Member
Registered: 02 Apr 2019
Posts: 7

How to better end batch script exit / b or goto: eof?

Hi

How to better end batch script exit / b or goto: eof?

Offline

#2 02 May 2019 09:45

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,095

Re: How to better end batch script exit / b or goto: eof?

If you need to set the ERRORLEVEL for the script (or a subroutine) then you should use exit /b [number].

Otherwise they are pretty much interchangeable in my experience (happy to be corrected on this though) – so use whichever you prefer the look of I guess.

Last edited by bluesxman (02 May 2019 09:45)


cmd | *sh | Ruby | Chef

Offline

#3 02 May 2019 20:48

Aacini
Member
Registered: 05 Dec 2012
Posts: 148

Re: How to better end batch script exit / b or goto: eof?

I used to end subroutines (called by call) via exit /B, and end the main program (called at the command-prompt) via goto :EOF

Antonio

Last edited by Aacini (02 May 2019 20:49)

Offline

#4 03 May 2019 10:57

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 1,037
Website

Re: How to better end batch script exit / b or goto: eof?

Other than being able to return an ERRORLEVEL, I think that the only difference is that EXIT will work even if Command Extensions are disabled, thats a pretty rare edge case though.

Offline

Board footer

Powered by FluxBB