views:

108

answers:

1

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.

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.

Any help is definitely appreciated.

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
...
+11  A: 

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

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.

See call /? for more information.

Nick Meyer
Thanks Nick, this is almost certainly the issue. My script does call another batch file. I will verify it and re-comment once I find out if if it does/doesn't solve the problem.
tb
That was it. Much Appreciated.
tb