Home > Commands A-M > Batch L

:LABEL


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Used as the target of GOTO command(s).


Syntax

GOTO label

:label


Parameters
label (v2.0 Win95 NT4)
Batch file execution branches from GOTO and resumes at :LABEL.

Switches

none.


Related

Most commonly used with GOTO.


Notes
Prefix :LABEL with colon

The LABEL must begin with, at least, one colon (:).


Keep the first 8 :LABEL characters unique

The first 8 characters of the LABEL should be unique. Otherwise, when the GOTO is executed; it will choose the LABEL to transfer control to (and that could be the "wrong" LABEL, resulting in an infinite loop).


Using :LABEL as a fast REMARK

Use of a double colon (::) before a LABEL (::THIS IS A REMARK) is a "fast" batch remark (for some reason, DOS parses any REM command it finds; taking "extra" time).


Examples

The infinite loop:

    @ECHO OFF
    :AGAIN
     ECHO Press CONTROL+BREAK to stop!
     GOTO AGAIN

The fast (executes faster) remark:

    @ECHO OFF
    ::This is to remind me to backup...
     ECHO backup!

IF Branch to the appropriate message:

    @ECHO OFF
     FIND /I "error" < my.log
     IF ERRORLEVEL 2 GOTO LERROR
     IF ERRORLEVEL 1 GOTO LNOT
     IF ERRORLEVEL 0 GOTO LFOUND
     GOTO LEND
    :LERROR
     ECHO Houston, the "find" command had a problem!
     GOTO LEND
    :LNOT
     ECHO not found.
     GOTO LEND
    :LFOUND
     ECHO found at least once.
     GOTO LEND
    :LEND

Errorlevels

none.


Availability
Internal
DOS
v2.0 v2.01 v2.05 v2.10 v2.11 v2.11R v2.12 v2.2 v2.25 v3.0 v3.20 v3.05 v3.1 v3.21 v3.25 v3.30 v3.3A v3.3R v3.3T v3.31 v3.40 v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02 v6.0 v6.10 v6.2 v6.21 v6.22 v6.23 v7.00 v7.0R1 v7.10 v8.00
Windows
Win95 Win98 WinME
Windows NT
NT4 NT2000