Batch Script: Writing & Executing
Batch Script: Writing & Executing
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.
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.