Windows Commands: Direct a batch program to jump to a labelled line


GOTO-Windows Command

GOTO

Direct a batch program to jump to a labelled line.

Syntax
      GOTO label 
Key
label : a predefined label in the batch program. Each label must be on a line by itself, beginning with a colon.

For example:

IF %1==12 GOTO s_december
:: other commands
:s_december

GOTO :eof

An easy way to exit a batch script file without defining a label is to specify
GOTO :eof
this transfers control to the end of the current batch file.

Using a variable as a label

CHOICE
goto s_routine_%ERRORLEVEL%

:s_routine_0
echo You typed Y for yes

:s_routine_1
echo You typed N for no

Skip commands by using a variable as a :: comment (REM)

In this example the COPY command will only run if the parameter "Update" is supplied to the batch

@echo off
setlocal
IF /I NOT %1==Update SET _skip=::

%_skip% COPY x:\update.dat
%_skip% echo Update applied
...

If Command Extensions are disabled GOTO will no longer recognise the :EOF label

Other Windows 98, Windows XP Commands:
addusers , arp , assoc , associate , at , attrib , browstat , cacls , call , cd , change , chkdsk , chkntfs , choice , cipher , cleanmgr , clip , cmd , color , comp , con2prt , copy , date , defrag , del , delprof , dir , diruse , diskcomp , diskcopy , doskey , dsadd , dsmod , echo , endlocal , exit , expand , expand , fc , fdisk , find , findstr , for , forfiles , format , fsutil , ftp , ftype , global , goto , help , hfnetchk , if , ifmember , ipconfig , kill , label , ldifde , local , logevent , logoff , logtime , mapisend , md , mem , mode , monitor , more , mountvol , move , moveuser , msg , msiexec , msinfo32 , mstsc , munge , mv , nbtstat , net , netdom , netsh , netstat , netsvc , now , nslookup , ntbackup , ntrights , path , pathping , pause , perms , ping , popd , portqry , print , prncnfg , prnmngr , prompt , pushd , qgrep , rasdial , rasphone , rd , rdisk , recover , reg , regedit , regsvr32 , rem , ren , replace , rmtshare , robocopy , route , runas , rundll32 , sc , schtasks , sclist , scriptit , set , setlocal , setx , share , shift , shortcut , showgrps , showmbrs , shutdown , sleep , soon , sort , start , su , subinacl , subst , tasklist , time , timeout , title , touch , tracert , type , ver , verify , vol , where , whoami , windiff , winmsd , winmsdp , wmic , xcacls , xcopy ,
Live2Support.com :
Product - Benefits - Features - How Does it Works - Pricing - SSL Certificates - Signup - Contactus - Login - Submit Resources