(page requirements)

Writing your first BATch file

Generally speaking, batch files (files with the BAT extension such as AUTOEXEC.BAT) are text files that can contain a list of multiple commands to be executed. For example, you could write a BAT file to copy multiple files or change the directory or anything you can do using the "Command/DOS Prompt" commands.

It's very easy to create BAT files:

  • Go to the "DOS Prompt" or "Command Prompt"
  • Type following commands in red line by line (press ENTER after each line):


    COPY CON MYBAT.BAT

    ECHO Hello, world! This is my test BAT file!

    CD C:\WORK\9TO5\FOLDERA
    DIR C:\WORK\9TO5\FOLDERA

    ^Z



    Please note that "^Z" is a single character produced by pressing CTRL+Z
  • Run newly created BAT file by typing "MYBAT" and pressing ENTER.

In the above code, we're first saying "hello" to the world, changing the current directory to "C:\WORK\9TO5\FOLDERA" (example directory - you may type in your mostly visited directory here), and finally getting the directory of "C:\WORK\9TO5\FOLDERA"

Although we used the command line to create "MYBAT.BAT" itself, you can create your future BAT files using any text editor. You can then experiment with different commands in your new BAT file.

 
 
Applicable Keywords : MS-DOS, Windows NT, Windows NT 3.x, Windows NT 4.x, Windows, Windows 3.x, Windows 95
 
 
 
Copyright © 2009 Chami.com. All Rights Reserved. | Advertise | Created in HTML Kit editor