Basics of BATCH File

Basics of BATCH(.BAT) File













Introduction

A batch file is a script file in windows.
It is a plane text file which contains series of commands which needs to be executed by command line interpreter.
Batch files have .bat as extension.


Steps to create a batch file:

Step 1:Create a new text document
Step 2:Rename the file as per your choice and in the extension replace ".txt" by ".bat"
Step 3:Now Right click on the bat file and click on edit
Step 4:Type commands which needs to be executed and save the file.



Basic Commands:

  • cls -This command is used to clear the screen
  • ECHO - This command is used to display output to screen
    • The other variants of ECHO are:
                1.ECHO OFF- Doesnt display DOS commnads on the screen
                2.ECHO ON- Displays DOS commands on the screen
  • .Timeout seconds-It waits for specified amount of time(Seconds) before executing next command.User can skip the timer by pressing any key
  • .Pause - Pauses the running of a batch file and displays the message "Press any key to continue ..." on the screen
    •  The other variants of Pause commands are:
               1.pause {Displays "Press any key to continue ...".}

       2.pause < nul {Waits with no comment.}

               3.pause Do you want to continue? {Displays "Do you want to continue?" with                     "Press any key to continue ..." on the next line.}.
  • SET- Set will view the DOS environment or create, change, or delete environment values.
         

No comments:

Post a Comment