Reputation: 301
I have a batch file that i am testing, all i want to do is the following
CALL ping.bat
Then after that batch file has run i want to run another file:
CALL ping2.bat
Right now i have these two lines beside each other in a batch file the first batch file will fire successfully but the second one does not . Any suggestions?
CALL ping.bat
CALL ping2.bat
Ping .bat is just:
ping 127.0.0.1
Upvotes: 28
Views: 78127
Reputation: 3216
Assume you have 3 batch files.
If you have all the three batch files in a single folder,(lets say under C:\NewFolder) then if you double click ping3.bat, you won't get any error for sure.
Note: If you don't want to wait for the first command to complete, then use start keyword which just initiate the process and proceed with the next line in the batch file, whereas call
will do it sequentially(comes to next line only after the current process completes , start allows parallelism)
To do it parallel use the below two lines of code in the ping3.bat:
start ping1.bat
start ping2.bat
Upvotes: 5
Reputation: 211
The ping command acts differently on different operating systems. Try forcing the ping command to stop after a few echo requests with a -n switch.
ping -n 4 127.0.0.1
Upvotes: 0
Reputation: 1099
Not exactly sure what you wanted to do here, but I assume that you wanted to do this:
In that case, from your actual batch file, you should start ping.bat and ping2.bat like this:
::some code here
start /wait ping.bat
start /wait ping2.bat
::some code here
Then in both ping.bat and ping2.bat the last line should be exit. Their code should look like this:
::some code here, might be ping 127.0.0.1
exit
So now your actual batch file will start ping.bat and it will wait for it to finish (exit). Once the ping.bat closes, your actual batch file will go to the next line and it will start ping2.bat etc.
Upvotes: 2
Reputation: 77657
There's a chance your ping.bat
is simply calling itself, if its contents is merely ping 127.0.0.1
, as you say.
I would append .exe
after ping
to make things sure.
As jeb has by all means justly suggested, choosing a different name for your batch file is an even better solution.
Upvotes: 6
Reputation: 301
don't call the file you are calling from the batch the same name as the command you are trying to invoke...renamed to gnip.bat and works fine
Upvotes: 2
Reputation: 354386
Check that you don't have exit
somewhere in the first batch. Some people habitually use that to jump out of a batch file which is not the proper way to exit a batch (exit /b
or goto :eof
is).
Another option is that you might call another batch in the first one without call
.
Upvotes: 18