How to make a batch file.

Pv

 

A batch file is a script file in Microsoft Windows. Batch file contains instructions and commands that has to be run in command prompt.

It helps automate routine tasks without requiring user input or intervention. Some common applications of batch files include loading programs, running multiple processes or performing repetitive actions in a sequence in the system.

How to make a batch file ?

Firstly we will just make a simple batch file.
step 1 -> Open notepad or any text editor.

step 2 -> On the first line type "@echo off".
step 3 -> Now type "This is basic batch file".
step 4 -> Type "pause".


step 5 -> Now save it as all files and with name like "filename.bat". Remember to put ".bat" at the end.

You had created a simple batch file.


Now, you will learn to create more advance batch file with some commands.

Take a look at some basic commands ->

ECHO - With this command you can print any text. You can use it like - echo "hey there".
CLS - This command is used to clear the screen of command prompt. You can simply type Cls to clear the screen.
REM -  If you had ever learnt a programming language you now what is comment. REM if you used to prevent something from executing.
DEL - This is used to delete a file. you can use it like - del C:\filename.txt
COPY - It is used to copy a file from a location to other. you can use it like - copy C:\filename.txt C:\documents
TITLE - This command is used to change the title of the window. You can use it like - Title New tittle
EXIT - By this command you can exit from command prompt.
MKDIR - If you want to create a directory you can use this command. This command is used to create directories. To create directory - mkdir C:\folder
RMDIR - It is used to remove a directory. You can use it like - rmdir /s folder
START - start is used to open a program. it's use - start firefox.exe
 

Now you can make a batch file and do some executions using commands which you have learnt.


Thanks for reading   :)


Tags

Post a Comment

0Comments

Please Select Embedded Mode To show the Comment System.*