| . EDIT command |
| o Usage: EDIT filename.bat |
| Where filename.bat is an optional parameter. We are
recommended to give a name when we open the editor because
it will simplify some steps in saving the file when it's done. |
| |
| o Run EDIT command at the command prompt, we will
go to an editor mode, normally in blue screen. Make sure
we have saved the file upon completion. |
| |
| o Remember to give an extension of .BAT in your batch file. |
| |
| |
| . COPY command |
| o Usage: COPY con filename.bat |
| Where filename.bat is a required
parameter if we want to save the file. We must give a name when we run COPY command. |
| |
| This method is useful when you are writing a short batch file. |
| o "COPY con filename" |
| 1. Similar to backup a file using COPY command, "COPY con
filename" means copying from "con" (the source) to a file called
filename.bat (the target). |
| |
| 2. CON is a reserved name for console. The keyboard is known to MS-DOS as console. |
| |
| 3. By running the command, we instruct MS-DOS to copy
what we type from the keyboard to a file filename.bat .
When MS-DOS display a blinking cursor instead of a command
prompt, it means it's ready for we to type in any text. |
| |
| 4. Remember to use Ctrl-Z (i.e. hold down the ctrl key
and hit Z) or press the function key F6 to end the file.
MS-DOS will display ^Z on the screen. It is the end of file marker. |
| |
| 5. And then, press Enter to save the file. MS-DOS will
signal back "1 file(s) copied" and return to the command prompt. |
| |
| |
| . DOSKEY command |
| o Usage: DOSKEY /h > filename.bat |
| |
| o This method is useful for a "write-and-test" approach.
While we are writing a batch file, we are working on the command
prompt directly. By the way, we can know the result of every command immediately. |
| |
| o The DOSKEY program, once loaded into memory, keeps
track of the commands we have typed through the keyboard. |
| |
| o DOSKEY /h -- displays all commands stored in memory. |
| |
| o By running the command, we instruct MS-DOS to redirect
the history of commands to a batch file filename.bat . |
| |
| o Steps in using this method: |
| 1. Make sure DOSKEY program has been loaded into memory. |
| |
| 2. Press Alt-F7 to clear the memory buffer before we "write-and-test" our file. |
| |
| 3. Run the commands that we want to put in the batch file. |
| |
| 4. Upon completion, run DOSKEY /h > filename.bat |
| |
| 5. Run EDIT filename.bat to delete the last
line "i.e. DOSKEY /h > filename.bat" and all other
unnecessary lines, if necessary. |