goto
秃噜豆儿 发表于 2020-06-23 11:36浏览次数:
goto命令就是把批处理文件移动到特定的标签或位置,允许用户根据输入或事件选择重新运行或跳过其他行。
MThe goto command moves a batch file to a specific label or location, enabling a user to rerun it or skip other lines depending on inputs or events.
目录:
1 goto 运行系统环境
2 goto 语法
3 goto 示例
goto 运行系统环境
Windows 95
Windows 98
Windows xp
Windows vista
Windows 2000
Windows 7
Windows 8
Windows 10
Windows NT
Windows ME
MS-DOS 3.00 及以下
goto 语法
GOTO label
label
|
指定在批处理程序中用作标签的文本字符串。
|
您可以单独在一行上输入一个标签,并以冒号开头。
Windows 2000,Windows XP和更高版本的其他语法
如果启用了命令扩展,则goto将更改如下:
现在,goto命令接受:EOF的目标标签,该标签将控制权转移到当前批处理脚本文件的末尾,这是无需定义标签即可退出的简便方法。输入CALL /?有关使此功能有用的CALL命令扩展的说明。
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.
Windows 2000, Windows XP, and later additional syntax
If Command Extensions are enabled GOTO changes as follows:
GOTO command now accepts a target label of :EOF that transfers control to the end of the current batch script file, which is an easy way to exit without defining a label. Type CALL /? for a description of extensions to the CALL command that make this feature useful.
goto 示例
在下面的示例中,批处理文件将仅显示“ DONE”,而跳过goto和goto目标标签之间的所有内容。
GOTO END
ECHO SKIPPING THIS
:END
ECHO DONE
In the example below, the batch file would only print "DONE," skipping anything that is between the GOTO and the GOTO target label.
GOTO END
ECHO SKIPPING THIS
:END
ECHO DONE