运行批处理文件,从中调用另一个批处理,然后按ctrl + c,然后返回到第一个? [英] Running batch file, call another batch, ctrl+c out of that, then return to the first?
问题描述
我有一个批处理脚本,它挂载一个.vhd文件并创建一个结点,它调用的另一个批处理脚本在已挂载的vhd/结点上运行某些操作.该脚本完成后,它将返回到第一个批处理脚本并删除连接点,卸载.vhd然后退出.
I have a batch script which mount's a .vhd file and creates a junction point, the it call's another batch script which runs some things on the mounted vhd/junction point. When that script finishes, it then comes back to the 1st batch script and deletes junction point, unmounts .vhd then exits.
问题在于,当大多数用户只是ctrl + c并关闭第二个脚本时,第二个脚本需要正确退出才能运行其余的第一个脚本.
The problem is the second script needs to exit properly in order to run the rest of the first script, when most of the users will just ctrl+c and close the second script.
是否可以通过不允许ctrl + c取消或在调用发生后以某种方式重新启动第一个批处理文件来防止这种情况的发生?
Is it possible to prevent this from happening, either by not allowing the ctrl+c cancel or somehow restart the first batch file after the call has happened?
推荐答案
感谢Endoro的回答,即使它对我不起作用,也让我记住了开始,但我总是忘记了开始,只使用通话.无论如何,我发现的解决方案是这样做:
Thanks to Endoro's answer, even though it didn't work for me, it made me remember start, i always forget start and just use call. anyway the solution i found was was to do this:
2>nul (
echo N|start /wait "" cmd /c C:\2nd-batch.BAT
)
它为2nd-batch.bat创建了一个新窗口,该窗口允许dumbuser甚至通过X按钮退出它,并且它仍然完成了1st-batch.bat的其余部分
it creates a new window for the 2nd-batch.bat which allows the dumbuser to even exit it via the X button and it still completes the rest of the 1st-batch.bat
这篇关于运行批处理文件,从中调用另一个批处理,然后按ctrl + c,然后返回到第一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!