Batch commands or programs are also commonly known as batch files. They are essentially simplified scripts that support the execution routine or repetitive tasks. A batch program is written as a text file with one or more command lines that are executed sequentially from top to bottom. They are identified by either a .bat or .cmd extension to their file names.
All Windows Server 2003 commands and many applications can be executed from a batch file. To provide greater flexibility, a number of conditional parameters, shown in Table A.25, can be set.
Option |
Description |
---|---|
call |
Permits the execution of another batch program without terminating the parent program. |
echo |
Turns the display of command action on or off as the batch file is executed. Can also be used to output a message to the screen—for example, "One moment please, while searching..." |
endlocal |
Ends the setlocal command described below. |
for |
Executes a specific command for every file in a set of files. Can also be run directly from the command prompt. |
goto |
Directs Windows Server 2003 to process the line in the batch file that is specified. |
if |
Processes a command when the specified condition is true; ignored when the condition is not met. The conditions of NOT and ELSE can also be used in combination as part of this option. |
pause |
Temporarily suspends the batch file until the user takes an action such as pressing a key to confirm an action. |
rem |
Short for remarks that can be added to the batch file for referencing. These are programming notes that are not executed. |
setlocal |
Permits the establishment of new localization variables. The localization is retained until the endlocal option resets the environment. |
Shift | (pipe) |
Modifies the position of parameters in a batch program and permits thestringing together of multiple commands on one line. |
> |
Outputs command results to the directed point. |
() |
Groups commands. |
|| |
Executes either the first or next command. |
&& |
Executes the first command and, if successful, executes the next one. |
Top |