VirtualBox

source: vbox/trunk/tools/bin/retry.cmd@ 78307

Last change on this file since 78307 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to CRLF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1@echo off
2rem $Id: retry.cmd 76553 2019-01-01 01:45:53Z vboxsync $
3rem rem @file
4rem Windows NT batch script that retries a command 5 times.
5rem
6
7rem
8rem Copyright (C) 2009-2019 Oracle Corporation
9rem
10rem This file is part of VirtualBox Open Source Edition (OSE), as
11rem available from http://www.virtualbox.org. This file is free software;
12rem you can redistribute it and/or modify it under the terms of the GNU
13rem General Public License (GPL) as published by the Free Software
14rem Foundation, in version 2 as it comes in the "COPYING" file of the
15rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17rem
18
19rem
20rem Note! We're using %ERRORLEVEL% here instead of the classic
21rem IF ERRORLEVEL 0 GOTO blah because the latter cannot handle
22rem the complete range or status codes while the former can.
23rem
24rem Note! SET changes ERRORLEVEL on XP+, so we have to ECHO
25rem before incrementing the counter.
26rem
27set /a retry_count = 1
28:retry
29%*
30if %ERRORLEVEL% == 0 goto success
31if %retry_count% GEQ 5 goto give_up
32echo retry.cmd: Attempt %retry_count% FAILED(%ERRORLEVEL%), retrying: %*
33set /a retry_count += 1
34goto retry
35
36:give_up
37echo retry.cmd: Attempt %retry_count% FAILED(%ERRORLEVEL%), giving up: %*
38set retry_count=
39exit /b 1
40
41:success
42if %retry_count% NEQ 1 echo retry.cmd: Success after %retry_count% tries: %*!
43set retry_count=
44exit /b 0
45
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette