
A batch file is a MS-DOS, OS/2 and Windows text file that is edited by a user with commands that are run each time the file is run. The file can run a sequence of commands and are typically used to run repetitive processes automatically. The file extension for MS-DOS is .bat, and for Windows 9x, it is .bat. The commands are interpreted line by line and are executed as they are written in the file. The file can be written in any text editor, such as Notepad in Windows
Instructions
MS-DOS
1
Open a command window. In the command line, type the "edit" command followed by filename.bat then press enter. "Filename" is your chosen name of the new batch file. This will open the blue edit screen. For example: "edit test.bat" creates a batch file called "test" and allows you to edit the file. Enter the line without the quotation marks.
2
Enter the commands you want the batch file to run when it is executed, one command per line. For example:
@echo off
echo Hello
Pause
@echo on
This code displays the word "Hello" until the user presses a key, then terminates.
3
Click "File" then "Exit" once you have finished. When the program asks whether or not to save the file, click "Yes."
4
Type the batch file's name into the command line then press "Enter." If the file has been created correctly then the instructions within the file will be executed.
Windows
1
Click the "Start" button on the Windows taskbar. Go to your program files list, find and open Notepad. Alternatively, you may click "Start," then click "Run" then type "notepad" into the command line and press "Enter."
2
Type the instructions you wish the file to execute each time it is run. For example:
@echo off
echo Hello
Pause
@echo on
This code displays the word "Hello" then waits for a user to press a key, then terminates.
3
Click "File" then click "Save as" from the drop-down menu. Choose the location where you want to save the file.
4
Click "All Files" from the "Save as type:" box. Enter a file name for the file then click the "Save" button. Put a ".bat" at the end of the file name.
5
Double-click the file's icon or type the file name into the "Run" command line in the "Start" menu to test the file.
No comments:
Post a Comment