> DOS 中文参考手册 > goto

GOTO

(go to)


在批处理文件中,把MS-DOS定向到某一行,这一行由指定的标号来标记。该命令只能用在批处理文件中。

GOTO命令在批处理文件中把MS-DOS定向到由标号指定的一行。当MS-DOS找到此标号,就从下一行开始执行命令。

GOTO label 

label 指定MS-DOS应转向哪一行。

★★★★★实例★★★★★:

下面的批处理文件把驱动器A的磁盘格式化为系统盘。若操作成功,GOTO命令就把MS-DOS定向到“end”标号。

echo off

format a: /s

if not errorlevel 1 goto end

echo An error occurred during formatting.

:end

echo Successfully formatted the disk in drive A.


Directs cmd.exe to a labeled line in a batch program.

GOTO label

  label   Specifies a text string used in the batch program as a label.

You type a label on a line by itself, beginning with a colon.

If Command Extensions are enabled GOTO changes as follows:

GOTO command now accepts a target label of :EOF which transfers control to the end of the current batch script file.  This is an easy way to exit a batch script file without defining a label.  Type CALL /?  for a description of extensions to the CALL command that make this feature useful.


上一篇:
下一篇: