1. #1
    Unregistered

    What is meant by batch files in Windows OS? How to create a simple batch file?

    I came to know that we can write scripts in Windows to by creating batch files, What is meant by the batch files in Windows? How to create a batch file?



  2. #2
    Support Array
    Join Date
    Apr 2012
    Posts
    1,574

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch files are nothing but a text file with a list of commands to execute with .bat extension. So what all commands which you run in the command prompt can be executed by creating the batch file. If you are set of commands which you want to run again several time then you can write it in a batch file and execute it in the command prompt.

    Steps to create a simple batch file is as follows,

    STEP 1: Open text pad from start or simply press Windows key + R and type notepad and press Enter.
    STEP 2: Now type the commands which you want to execute, as a simple batch file as follows,echo “My first simple batch file” ipconfig /all
    STEP 3: The command echo will output the text as “My first simple batch file” and the command ipconfig /all will show your network related informations.
    STEP 4: Now save the file as simplebatch.bat in your desired destination.
    STEP 5: Open cmd from start or press Windows key + R and type cmd and press Enter.
    STEP 6: Now navigate to your folder path and type the bat file name as simplebatch.bat and the commands will be executed.

    In this way you can create your own batch file with your own set of commands and execute them accordingly.
    ~Support
    Community Manager

  3. #3
    swagota paira Array
    Join Date
    May 2012
    Posts
    399

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch File can be used to make a set of Commands to execute in windows operating system.If u want to do series of activities in Windows then u can add all the commands in a batch file and it will executes all the commands one by one.Batch files are simple text file which will have some basic dos command and u can also run the system command that u can run in Windows command prompt.
    to create a simple batch file just open the "notepad" nd type the following commands:
    ECHO OFF (while running the commands in the command prompt it will not show the command that is executing)
    Dir (it will just list the files and folders in the directory)
    PAUSE (Pause will wait for the user input, press enter key of other key to continue)
    Ipconfig (Ipconfig is a Windows command which will display the network configuration of the system)
    Cleanmgr (Cleanmgr is a Windows utility command which will open the disk clean manager Window)

  4. #4
    Mantu Pandit Array
    Join Date
    May 2012
    Posts
    305

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Dear,

    These are the text files which are opens in the notepad, you can able to create it by using the notepad. and save the file as "Name.bat" in your known detination. now open RUN and type the cmd and press enter.

  5. #5
    rahulthelpd Array
    Join Date
    May 2012
    Posts
    9

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    batch file is actually a text file that contains commands for windows operating system
    these commands are used in DOS
    you can create batch files but firstly you would have to acuire knowledge about commands
    its not that easy like typing a notepad

  6. #6
    puru thaman Array
    Join Date
    May 2012
    Posts
    276

    Smile Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Hello Dude!!!

    _I Have Few Points For your Query_

    #Batch File_

    *Batch File is a Type of Script File,
    *A Text File Containing Series Of DOS Commands,
    *It Can Be Executed by Command Interpreter.

    #Creation Of Batch File_

    *Open Note Pad in Windows(It will Allow you to create File without unnecessary coding),
    *Type a Command which you want to Execute as Batch File,
    *Choose a File Name and Click Save,
    *Type @echo off into the first line of your Batch File,
    *Open Command Prompt and Type your Command,
    *Press Enter and choose path of folder,
    *Simply Type Batch File Name as batch.bat and then Commands will be Executed.
    batfile.png CropperCapture1.png CropperCapture2.jpg

    Thank You@@@

  7. #7
    rai.abhishek Array
    Join Date
    May 2012
    Posts
    9

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    When you are executing the batch file. You can just write the name in the command prompt.Even if there is an executable file with same name then also the batch file will be executed.

  8. #8
    belide Array
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    610

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch Files are list of Command Line Instructions that are batched in to a single file. It is very easy to use.
    It is saved with an Extension of '.bat'.

    Sample Batch code which clears Cookies on your Hard Disk when ever you go Online.

    1) Open Notepad.
    2) Type this code

    @ECHO OFF
    ECHO.
    ECHO This is a batch file
    ECHO.
    PAUSE
    CLS
    EXIT
    3) Save it as anyname.bat (aware that no .txt extension after .bat).
    4) Double Click on the Saved File.

    In this,

    ECHO is same as "Print".
    Pause is to continue when ever the User wants.
    CLS is to Clear.

  9. #9
    kranthi Array
    Join Date
    May 2012
    Posts
    388

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch files are nothing but the files which are created as a support for the existing files in the system and also you can create the batch files in your computer by making them as default files of the drives and also the proper settings for the batch files to create them in your computer and as well as your windows OS.

  10. #10
    srikanth Array
    Join Date
    May 2012
    Posts
    215

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    batch files are the special files, often called scripts, that allow you to run the programs from the DOS command window. batch files are useful for storing sets of commonds that are always executed together, in sequence, because you can simply enter the name of the batch files as the "command" instead of entering each command individually

  11. #11
    mobeshpal Array
    Join Date
    May 2012
    Posts
    96

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    STEP 1: Open text pad from start or simply press Windows key + R and type notepad and press Enter.
    STEP 2: Now type the commands which you want to execute, as a simple batch file as follows,echo “My first simple batch file” ipconfig /all
    STEP 3: The command echo will output the text as “My first simple batch file” and the command ipconfig /all will show your network related informations.
    STEP 4: Now save the file as simplebatch.bat in your desired destination.
    STEP 5: Open cmd from start or press Windows key + R and type cmd and press Enter.
    STEP 6: Now navigate to your folder path and type the bat file name as simplebatch.bat and the commands will be executed.

    In this way you can create your own batch file with your own set of commands and execute them accordingly.

  12. #12
    BISMITH Array
    Join Date
    Jul 2012
    Location
    NEW DELHI
    Posts
    286

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Hi,
    Batch file are script file or text files which contains series of command to be executed by command prompt,which usually have .bat extension.
    steps to create a batch file-
    1.go to to notepad and type
    ECHO@ OFF
    ECHO.
    ECHO MY FIRST BATCH FILE
    ECHO.
    CLS
    EXIT
    Go to file and save with name eg1.bat
    now exit the notepad window
    double click the file which you have saved,your`s batch file will open.
    similarly you can write any command to the batch file an dit will get executed.

  13. #13
    milan padariya Array
    Join Date
    Jun 2012
    Posts
    221

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch Files are list of Command Line Instructions that are batched in to a single file. It is very easy to use.
    It is saved with an Extension of '.bat'.

    Sample Batch code which clears Cookies on your Hard Disk when ever you go Online.

    1) Open Notepad.
    2) Type this code

    @ECHO OFF
    ECHO.
    ECHO This is a batch file
    ECHO.
    PAUSE
    CLS
    EXIT
    3) Save it as anyname.bat (aware that no .txt extension after .bat).
    4) Double Click on the Saved File.

    In this,

    ECHO is same as "Print".
    Pause is to continue when ever the User wants.
    CLS is to Clear.,,,,,,,,,,,,,,,,,,,,,,,,,,,,

  14. #14
    kumar12337 Array
    Join Date
    Sep 2012
    Location
    hyd
    Posts
    1,989

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    hi dear friend......The batch file is nothing but...automatic execution file

    by using this we can ...execute the program automatically......and follow this steps to create the batch file....


    Now i'm going to show a example of batch file:

    first open the note pad or press windows key + r and type in that notepad and press enter

    then in that notepad ....type like this

    ver
    chkdsk
    appwiz.cpl
    control
    cmd

    after the above ....save it as name.bat

    then open it and see ......the above commands will automatically executes.....................ALL THE BEST

  15. #15
    S_DABAS Array
    Join Date
    Aug 2012
    Location
    delhi
    Posts
    376

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch files are used to create the commands which helps to run in sequence when the batch file has*been executed.
    It can be used to run commands an deleting series of files, moving files, etc.
    It does not require any special skills.
    It can be created by users who have a basic understanding of MS-DOS commands.
    It also can be run commands or programs through the command line.
    This batch file contained all they commands,.

  16. #16
    Darling Array
    Join Date
    Sep 2012
    Posts
    71

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch File can be used to make a set of Commands to execute in windows operating system.If u want to do series of activities in Windows then u can add all the commands in a batch file and it will executes all the commands one by one.Batch files are simple text file which will have some basic dos command and u can also run the system command that u can run in Windows command prompt.
    to create a simple batch file just open the "notepad" nd type the following commands:
    ECHO OFF (while running the commands in the command prompt it will not show the command that is executing)
    Dir (it will just list the files and folders in the directory)
    PAUSE (Pause will wait for the user input, press enter key of other key to continue)
    Ipconfig (Ipconfig is a Windows command which will display the network configuration of the system)
    Cleanmgr (Cleanmgr is a Windows utility command which will open the disk clean manager Window)

  17. #17
    RONAK AGRAWAL Array
    Join Date
    Oct 2012
    Posts
    119

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Friend,
    Batch file is the name given to a type of script file, a text file containing a series of commands to be executed by the command interpreter.
    Batch File can be used to make a set of Commands to execute in windows operating system.
    If u want to do series of activities in Windows then u can add all the commands in a batch file and it will executes all the commands one by one.
    Batch files are simple text file which will have some basic dos command and u can also run the system command that u can run in Windows command prompt.


    To create a simple batch file just open the notepad, write some basic DOS commands such as cal, echo "your name", cal, dir ,etc.
    Save it with the extension .bat.
    double click the file to run.
    it will run all the commands entered in it.

  18. #18
    Temjenchiba Array
    Join Date
    Oct 2012
    Posts
    9

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Batch files are regarded as scripts or simply text files. they are a set of commands which functions is to execute programs. they are mainly used when there are many programs or files to be executed. sometimes batch files are termed as dos files as they work with commands like the dos.in order to run the batch file, first you need to open the notepad and then type the following commands,ECHO OFFDIRPAUSECLEANMGRafter gave any name followed by .bat and then save it. now, when you double click the name you have saved it start functioning with all the commands you have typed.

  19. #19
    gauravgpt Array
    Join Date
    Jul 2012
    Posts
    853

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Hello friend..

    A batch file is an unformatted text file that contains one or more commands and has a .bat or .cmd file name extension. When you type the file name at the command prompt, Cmd.exe runs the commands sequentially as they appear in the file.
    You can include any command in a batch file. Certain commands, such as for, goto, and if, enable you to do conditional processing of the commands in the batch file.

    Create a sample batch file:-

    In order to create a sample batch file open notepad and type the following command and save the file as Test.bat

    ECHO OFF
    Dir
    PAUSE
    Ipconfig
    Pause
    Cleanmgr

    ECHO OFF is DOS command and while running the commands in the command prompt it will not show the command that is executing.

    Dir will just list the files and folders in the directory.

    Pause will wait for the user input, press enter key of other key to continue.

    Ipconfig is a Windows command which will display the network configuration of the system.

    Cleanmgr is a Windows utility command which will open the disk clean manager Window.

    Once the batch file is created and you can double click the batch file using the mouse and it will start executing the series of Dos commands and other command that you typed in the Batch File


    All the Best!!

  20. #20
    ajjuravi Array
    Join Date
    Jun 2012
    Posts
    562

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    Dear friend,

    If we want our OS to perform a series of operations in System, then we compose a Batch File.

    Batch file is simply a list of commands written in a text file. You can create a Batch by simply writing DOS Commands in Notepad and saving it to .bat format.

    In this way, your Batch file will be created and you can access it by opening cmd.

    For opening cmd, open Run Command and type cmd followed by OK.

  21. #21
    ak47 Array
    Join Date
    Jan 2013
    Posts
    493

    Re: What is meant by batch files in Windows OS? How to create a simple batch file?

    What is a batch file?
    Batch files are special files, often called scripts, that allow you to run programs from the DOS Command Window. Batch files are useful for storing sets of commands that are always executed together, in sequence, because you can simply enter the name of the batch file as the "command" instead of entering each command individually.
    In DOS, batch files end with a .BAT extension. The process of creating them is often called DOS batch scripting.


    A Simple Example
    Suppose the following text is saved in a file called "mybat.bat":
    @ECHO ON
    REM This is an example .BAT file output...
    @ECHO OFF

    REM Nothing fancy...
    dir

    This batch file contains two comments (or remarks, indicated by "REM") that just provide documentation for either the author or the user of the file. The first one is "echoed" to the screen because it is embedded inside two @ECHO commands that first turn on echoing and then turn it off. Everything between the @ECHO commands is displayed on the screen during the script's execution. After the second comment, there is a simple DOS "dir" command which, as usual, lists the contents of the current directory.

    Note that the individual commands or comments are separated by newlines, that is, pressings of the Enter key.

    Running the batch file executes the commands in "mybat.bat" sequentially.

    Invoking the Batch File

    A batch file can be run in two ways:

    • Straight from the command line
    • Double-clicking the file's icon in a Windows Explorer window (or via "My Computer")
    For our example above, typing "mybat" or "mybat.bat" at the DOS command line yields the following output:



    Double-clicking the batch file icon (see below) will open up a DOS Command Window, invoke NetMailBot within it according to the batch file, and then close the window when everything is done. Depending on how short your script is, if you blink, you might miss it!

    A batch file icon:

    1. Click Start
    2. Click Run
    3. Type: notepad and press enter.
    4. Once notepad is open, type the below lines in the file or copy and paste the below lines into notepad.

      @echo off
      echo Hello this a test batch file
      pause
      dir c:\windows
    5. Click File and click Save; browse to where you want to save the file. For the file name, type "test.bat", and if your version of Windows has a "Save as type" option, choose "All files", otherwise it will save as a text file. Once all of this has been done click the Save button and exit notepad.
    6. Now, to run the batch file, double-click or run the file like any other program. Once the batch file has completed running it will close the window automatically.
    Batch commands
    Just like all MS-DOS commands, all batch file commands are not case sensitive. However, in the below listing we have listed all commands in all caps to help you identify what is a command and what is not.
    @ Does not echo back the text after the at symbol. This most commonly used as @ECHO OFF to prevent any of the commands in the batch file from being displayed, just the information needed.
    %1 The percent followed by a numeric value, beginning with one, allows users to add variables within a batch file. The below line is an example of what can be used in a batch file.ECHO Hello %1
    When the above one-line batch file is created, add your name after the batch file. For example, typing myname (being the name of the bat file) and then your name:
    myname bob
    would output:
    Hello bob
    Note: This can be extended to %2, %3, and so on.
    :: One of two ways of adding remarks into the batch file without displaying or executing that line when the batch file is run. Unlike REM this line will not show regardless if ECHO off is in the batch file.
    :LABEL By adding a colon in front of a word, such as LABEL, you create a category, more commonly known as a label. This allows you to skip to certain sections of a batch file such as the end of the batch file. Also see GOTO.
    CALL This used to run another batch file within a batch file. When the batch file that is called is completed, the remainder of the original batch file is completed. Note if the batch file does not exist it will give an error message.
    CHOICE See running different programs for an example of how to use this command.
    • Additional information and the syntax of this command in each version of Windows and MS-DOS can be found on our CHOICE command page.
    CLS Just like the DOS command would clear your screen.
    • Additional information and the syntax of this command in each version of Windows and MS-DOS can be found on our CLS command page.
    ECHO Will echo a message in the batch file. Such as ECHO Hello World will print Hello World on the screen when executed. However, without @ECHO OFF at the beginning of the batch file you'll also get "ECHO Hello World" and "Hello World." Finally, if you'd just like to create a blank line, type ECHO. adding the period at the end creates an empty line.
    EXIT Exits out of the DOS window if the batch file is running from Windows.
    • Additional information and the syntax of this command in each version of Windows and MS-DOS can be found on our EXIT command page.
    GOTO LABEL Used to go to a certain label, such as LABEL. An example of GOTO would be to GOTO END. For an example of this see running different programs.
    • Additional information and the syntax of this command in each version of Windows and MS-DOS can be found on our GOTO command page.
    IF Used to check for a certain condition if the condition exists. If that condition exists it will perform that function. To see an example of this see running different programs.
    • Additional information and the syntax of this command in each version of Windows and MS-DOS can be found on our IF command page.
    PAUSE Prompt the user to press any key to continue.
    REM One of two ways of adding remarks into the batch file without displaying or executing that line when the batch file is run.
    SHIFT Changes the position of replaceable parameters in a batch program.
    START Used for Windows 95, Windows 98, and Windows NT 4.0 and above to start a windows application; such as START C:\WINDOW\CALC would run the Windows Calculator. Users running Windows 3.x need to utilize the WIN command. For example, WIN C:\Windows\CALC.EXE would run Windows and then Calculator after Windows has finished loading.

+ Reply to Thread

Similar Threads

  1. Replies: 92
    Last Post: 13-09-2013, 11:43 AM
  2. Replies: 23
    Last Post: 27-08-2013, 09:32 PM
  3. Replies: 12
    Last Post: 14-11-2012, 02:26 PM