Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page




 

Microsoft DOS goto command

Quick links

About goto
Availability
Syntax
Examples

About goto

Moves a batch file to a specific label or location, enabling a user to rerun a batch file or skip other lines depending on user inputs or events.

Availability

The goto command is an internal command that is available in the below Microsoft operating systems.

MS-DOS 3.00 and above
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP

Index

Category:
MS-DOS

Companies:
Microsoft

Related Pages:
Operating systems

Resolved

Were you able to locate the answer to your questions?

Syntax

Directs Windows 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.

Windows 2000 and Windows XP additional syntax

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.

Examples

In the below example, 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

  • Additional information about looping a batch file can be found on document CH001050.
  • See batch file page for additional examples and uses of the choice command.

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope