- When you need to perform similar administrative tasks on a regular basis on a single computer.
- When you need to perform a series of administrative tasks on a number of computers
- in the network.
- When you want to run specific administrative tasks on remote computers and it is
- not possible to go to the computer and work on a GUI.
- When you want to organize the output of commands run on a computer.
- When you need to repeat exactly the same administrative tasks on a number of
- computers.
You do not need to be a programmer to create batch files. Batch files are simple collections of commands combined with some operators and parameters. Just open Notepad and write a few simple commands as follows:
Rem * This file is my first batch file *
Echo My First Batch File
Echo Off
Dir
Echo You Just Saw Directory Listing
Echo Bye For Now
When you are done writing these lines, save the file as Mybatch.bat. Open the command prompt, type Mybatch, and press Enter.You will see the output of the batch file displayed in the command shell window.
You might have noticed that all commands used in the batch file are also displayed as they are processed. Every time a command is processed, the command prompt is displayed along with the command itself.To get around this problem, you can use the Echo Off command. This stops commands from being displayed when they are processed.You use the Rem statement in the beginning of the file to insert comments into the file.The text after the Rem command is not processed.You use the Echo command to display a message.
Note: Batch files are considered executable files. You do not need to add the .bat extension from the command line when running batch files. This means that it does not make any difference whether you type Mybatch.bat or Mybatch at the command prompt.
Echo My First Batch File
Echo Off
Dir
Echo You Just Saw Directory Listing
Echo Bye For Now
When you are done writing these lines, save the file as Mybatch.bat. Open the command prompt, type Mybatch, and press Enter.You will see the output of the batch file displayed in the command shell window.
You might have noticed that all commands used in the batch file are also displayed as they are processed. Every time a command is processed, the command prompt is displayed along with the command itself.To get around this problem, you can use the Echo Off command. This stops commands from being displayed when they are processed.You use the Rem statement in the beginning of the file to insert comments into the file.The text after the Rem command is not processed.You use the Echo command to display a message.
Note: Batch files are considered executable files. You do not need to add the .bat extension from the command line when running batch files. This means that it does not make any difference whether you type Mybatch.bat or Mybatch at the command prompt.
Post a Comment