A batch file is a text file that contains a sequence of commands for a computers operating system. It is created mostly using the notepad application.

The batch file has an extension of " .bat "

PAUSE - Command is used to keep the terminal open , even after the command is executed

@ECHO OFF - Makes the entered commands to stay invisible and it won't be shown on the command prompt

ECHO - Command prints any text or symbols on the screen

ECHO. - The ( echo period ) command is used to show bank spaces between the lines

We can create variable using the command , " set variable=value " and you want to print the value use the command " echo %variable% " . So when a variable is mentioned inside the percentage signs it displays the value.

We can ask the user to set the variable using the following command , " set /p <variablename> = ">" " . Then print the variable using , echo " %variable name% "

We can also perform arithmetic operations , see the below example for more details. In the below "/a" specifies that the string to the right of the variable is a numerical expression that needs to be evaluated.

Untitled

A real time example , shutdown scheduler script.

Untitled

we can add comments to the script using the command , " rem or :: "

For Example " :: This is a shutdown script "  or " rem This is an another command to enter comments in a batch script "

IF ELSE command is a conditional statement and it uses the below comparison parameters

Untitled

Various examples of an IF ELSE Program

Untitled

IF , ELSE IF ,ELSE statement to run multiple conditions

Untitled