I have a batch file that calls various commands, some of which will occasionally fail due to network issues. Re-trying the command will usually result in success.

How can I re-try the commands automatically, up to a set number of tries?

Here is the some pseudo code that aims to explain further

```
call:try numTries "command and arguments"
exit

:try
REM execute %2, trying upto %1 times if it fails
%1 = %1 -1
eval %2
if %errorlevel%==0 exit \B
if %1 > 0 goto try
exit \B

```