0% found this document useful (0 votes)
38 views3 pages

Batch Script: Writing & Executing

The document discusses batch scripting which allows automating repetitive command sequences. It provides an overview of batch scripts, their features, common uses, and how to write and execute them. Batch scripts are plain text files with command lines that are run sequentially and can automate tasks like server setup, housekeeping, and application deployment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

Batch Script: Writing & Executing

The document discusses batch scripting which allows automating repetitive command sequences. It provides an overview of batch scripts, their features, common uses, and how to write and execute them. Batch scripts are plain text files with command lines that are run sequentially and can automate tasks like server setup, housekeeping, and application deployment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

BATCH SCRIPT

OVERVIEW
To automate command sequences that are repetitive in nature, batch script is included. Using
scripting, one can eliminate this requirement by automating these command sequences to make life at
the shell simpler and more efficient. The majority of businesses use batch script in some capacity to
automate processes. Batch scripts are kept in plain text files with lines of commands that are
performed one after the other in order. These files have the unique BAT or CMD extension. The
command interpreter is a system file that provides an interface (sometimes referred to as a shell)
through which files of this type are recognized and run. This interpreter is known as cmd.exe on
Windows platforms. It only takes a single click to execute a batch file. The Start-Run line or a
command prompt can also be used to execute batch files. Unless the file's path is in the path
environment in this situation, the entire path name must be utilized. Here is a straightforward batch
script example. When this batch script is executed, all files in the current directory are deleted.

BATCH SCRIPT FEATURES


 can read user inputs so that more processing can be done with them.
 contains control constructs like for, if, while, and switch to improve automation and scripting.
 advanced features such as Functions and Arrays are supported.
 regular expressions are supported.
 other programming languages, such as Perl, can be included.

COMMON USE OF BATCH SCRIPT

 setting up servers for various uses.


 housekeeping tasks such as eliminating unneeded files or log files can be automated.
 automating application deployment from one environment to another.
 installing apps on many PCs at the same time.

ENVIRONMENT
Writing & Executing
Notepad is commonly used to create batch files. This is the most basic tool for creating batch
files. The batch scripts' execution environment is next. This is done on Windows systems using the
command prompt or cmd.exe. In this environment, all batch files are executed.
Different Ways to Launch cmd.exe
Method 1 - Navigate to C:WindowsSystem32 and double-click the cmd.exe file.

Method 2 - Using the run command - The screenshot below illustrates how to locate the command
prompt (cmd.exe) on Windows.
The following screen will appear once cmd.exe has been opened. This is the environment in
which your batch scripts will run.

Environment & Variables


To launch batch files from the command prompt, either navigate to the directory where the
batch file is saved or put the file location in the path environment variable. Assuming the batch file is
saved in C:\Application\bin, you would need to follow these procedures to include the PATH
variable.

You might also like