windows 批处理文件:返回给调用者?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6728691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Batch File: Return to caller?
提问by user541686
What is the equivalent of the return
statement for a batch file subroutine?
return
批处理文件子程序的语句等效于什么?
采纳答案by Greg Hewgill
回答by Aacini
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.
不仅因为它使用起来更容易理解,还因为 exit /b (也只是退出)可能会向调用程序返回 exitCode (ERRORLEVEL) 值。
In my modest opinion, goto :eof is a strange patch that should not be used...
在我看来, goto :eof 是一个不应该使用的奇怪补丁......
回答by GaryNg
Goto :Eof
Exit
Goto :Eof usually use in call command such as:
Goto :Eof 通常用于调用命令,例如:
@echo off
call :Hi
pause&exit
:hi
echo Hello!
goto :eof