问题描述
我有以下问题:
我创建了一个批处理脚本自称在那里(下也可以写入日志并行)。在脚本,我开始另一个进程(如启动startServer.bat
),它启动一个java进程,并不断开辟了所有的时间。
I have created a batch script which calls itself in there (for being able to write a log in parallel). In the script I start another process (like start startServer.bat
) which starts up a java process and keeps opened up all the time.
在我最初的剧本我等待30秒,检查进程正在运行,做一个:
In my original script I wait 30 seconds, check if the process is running and do an:
exit /B 0
不幸的是,这并不工作,窗口显示的退出/ B 0正在评估,但窗口仍保持打开状态。当我关闭窗口与其他工艺(意为子进程在我的蝙蝠启动)我的脚本继续运行。
Unfortunately that does not work, the window shows that the exit /B 0 is being evaluated, but the window still keeps open. When I close the window with the other process (meaning the "child" processes started up in my .bat) my script continues its run.
所以:
scriptA.bat
-> in there I call: start startServer.bat
-> wait 30 seconds
-> check is server is started
-> exit /B 0
Process hangs up!
什么是很奇怪的,如果我环绕,像另一个脚本:
What's very odd, if I wrap another script around, like:
scriptB.bat
-> call scriptA.bat
-----> in there I call: start startServer.bat
-----> wait 30 seconds
-----> check if server is started
-----> exit /B 0
-> scriptA.bat continues without any hangup!
我也试过,退出0相同(无/ B)也同样的结果!在第一种情况下,它挂断,在第二种情况下我的窗口关闭预期...
I also tried the same with exit 0 (without /B) also, same result! In the first case it hangs up, in the second case my window closes as expected...
有你们有谁收到这样的问题,并且知道什么是错在这里?
流程挂断!
Has anyone of you ever had such a problem before and knows what's wrong here?Process hangs up!
推荐答案
还有的在这里退出批处理脚本的所有选项一个很好的解释:
There's a good explanation of all the options for exiting a batch script here:http://www.robvanderwoude.com/exit.php
具体而言,从该页面:
在DOS联机帮助(HELP EXIT)的/ b参数退出脚本的当前实例,这不一定是一样退出当前脚本无法说清楚。
即如果脚本是在一个名为一块code的,退出/ B退出CALL,而不是脚本。
Specifically, from that page:The DOS online help (HELP EXIT) doesn't make it clear that the /B parameter exits the current instance of script which is not necessarily the same as exiting the current script.I.e. if the script is in a CALLed piece of code, the EXIT /B exits the CALL, not the script.
所以,你绝对不希望退出/ B 0
在这种情况下。如果只是 0退出
不工作,尝试 GOTO:EOF
。
So you definitely don't want exit /b 0
in this case. If just exit 0
doesn't work, try GOTO:EOF
.
这篇关于出口/ B 0不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!