.bat脚本只执行1行 [英] .bat script only executes 1 line

查看:1238
本文介绍了.bat脚本只执行1行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个脚本多次执行相同的函数,但是当我运行脚本时,只有一个命令执行,其余的没有执行.bat文件运行后。

I'm writing a script that performs the same function several times, but when I run the script only one of commands executes leaving the rest not executed after the .bat file has run.

这与我的命令运行所需的时间(15-20秒)有关吗?我写了大量的bat文件,我从来没有遇到这种情况。我需要在每个命令之间有一个睡眠功能吗?

Does this have to do with the long time it takes for my commands to run (15-20 sec)? I've written plenty of bat files and I've never run into this. Do I need to have a sleep function between each command?

我一直在尝试在谷歌这一个,但我可用的搜索词使我的搜索结果模糊和困难。

I've been trying to figure this one out on google, but my available search terms makes my search results vague and difficult.

任何帮助是绝对赞赏。

bat文件看起来像下面

the bat file looks something like the following

IF input1 == "search term" goto location
do something
do something
do something
etc
goto end of file
:location
do something else
do something else
do something else
...


推荐答案

您的做别的事行是否涉及调用另一个批处理文件?如果是,是否使用CALL命令?

Does one of your "do something else" lines involve calling another batch file? If so, do you use the CALL command?

如果要以递归方式调用另一个批处理文件,则需要使用CALL。否则,当调用的批处理文件退出时,它不会返回到调用批处理文件,并且只是退出。这是MS-DOS日期的遗迹;因为内存是一个溢价,MS开发人员决定批处理解释器不应该保持默认调用堆栈 - 所以如果你想要一个,你必须使用CALL。

If you want to call another batch file recursively, you need to use CALL. Otherwise, when the called batch file exits, it does not return to the calling batch file and simply exits. This is a relic from the MS-DOS days; since memory was at a premium, the MS developers decided that the batch interpreter shouldn't keep a call stack by default -- so if you wanted one, you had to use CALL.

有关详情,请参阅 call /?

这篇关于.bat脚本只执行1行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆