VirtualBox

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

Last change on this file since 98262 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to CRLF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1@echo off
2rem $Id: retry.cmd 98103 2023-01-17 14:15:46Z vboxsync $
3rem rem @file
4rem Windows NT batch script that retries a command 5 times.
5rem
6
7rem
8rem Copyright (C) 2009-2023 Oracle and/or its affiliates.
9rem
10rem This file is part of VirtualBox base platform packages, as
11rem available from https://www.virtualbox.org.
12rem
13rem This program is free software; you can redistribute it and/or
14rem modify it under the terms of the GNU General Public License
15rem as published by the Free Software Foundation, in version 3 of the
16rem License.
17rem
18rem This program is distributed in the hope that it will be useful, but
19rem WITHOUT ANY WARRANTY; without even the implied warranty of
20rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21rem General Public License for more details.
22rem
23rem You should have received a copy of the GNU General Public License
24rem along with this program; if not, see <https://www.gnu.org/licenses>.
25rem
26rem SPDX-License-Identifier: GPL-3.0-only
27rem
28
29rem
30rem Note! We're using %ERRORLEVEL% here instead of the classic
31rem IF ERRORLEVEL 0 GOTO blah because the latter cannot handle
32rem the complete range or status codes while the former can.
33rem
34rem Note! SET changes ERRORLEVEL on XP+, so we have to ECHO
35rem before incrementing the counter.
36rem
37set /a retry_count = 1
38:retry
39%*
40if %ERRORLEVEL% == 0 goto success
41if %retry_count% GEQ 5 goto give_up
42echo retry.cmd: Attempt %retry_count% FAILED(%ERRORLEVEL%), retrying: %*
43set /a retry_count += 1
44goto retry
45
46:give_up
47echo retry.cmd: Attempt %retry_count% FAILED(%ERRORLEVEL%), giving up: %*
48set retry_count=
49exit /b 1
50
51:success
52if %retry_count% NEQ 1 echo retry.cmd: Success after %retry_count% tries: %*!
53set retry_count=
54exit /b 0
55
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