60 likes | 140 Views
BATCH FILE is nothing but a text file which contains a series of batch or dos commands which can be executed sequentially and in Desired order. A batch file is created to reduce time by executing same commands Which is used to run frequently? To create one of this file you don’t need special programming skills just some basic understanding of MS-DOS and dos commands.<br>A Batch file has a extension .BAT and any primary name or first name of your choice. To run a batch file you just need to type the primary name of a file in dos prompt<br>for Example :: I have created a batch file name abc.bat to run this I will type abc in dos prompt and will Press Enter. Autoexec.bat is a prime example of a batch file which was used in earlier windows and msdos it would have necessary boot files which used to load every time computer booted. <br>
E N D
How to create a batch file? BATCH FILE is nothing but a text file which contains a series of batch or dos commands which can be executed sequentially and in Desired order. A batch file is created to reduce time by executing same commands Which is used to run frequently? To create one of this file you don’t need special programming skills just some basic understanding of MS-DOS and dos commands. A Batch file has a extension .BAT and any primary name or first name of your choice. To run a batch file you just need to type the primary name of a file in dos prompt for Example :: I have created a batch file name abc.bat to run this I will type abc in dos prompt and will Press Enter. Autoexec.bat is a prime example of a batch file which was used in earlier windows and msdos it would have necessary boot files which used to load every time computer booted. How to Write a Batch File? Step No 1 :: Go to Start ----> Run--- >Cmd Step No 2 :: Type the following Dos Commands to create a Batch file • c:\>copy con abc.bat (Press Enter) • dir • dir/p/w • copy con • del pa.exe • PRESS CTRL+Z OR F6 To save the file Now To run this .bat file just type abc in the command windows without the extension. The command which I have included in .bat file will be executed sequentially that means dir command will be executed first then dir/p/w then copy con so on all this command will be executed in an order. Create .Bat file using Notepad
Step No 1 :: Go to start---> Run --->Type Notepad Step No 2 :: Type the following command. Dir dir/p/w copy con del pa.exe Just save the file with a .bat extension shown in image below. Command Used In Batch file • ECHO :: This command is used to print text on the display unit .Anything written after echo is displayed on the screen. •ECHO OFF :: Echo off is written before starting of a bat file this tells the program don’t show the command while executing the code.
• CLS :: This command clears the screen of previous outputs. • CALL :: This command is used to run another batch script within a batch file.If the batch file which is called doesnot exist it will display a error message. • EXIT :: This command is used to exit from dos windows. • IF :: if is used to check certain condition. if the condition exists or comes out to true it will perform the given instruction. • REM :: It allows us to add comment or remark between the codes and this remark is not displayed while the batch file is executed. • GOTO :: It is used to go to LABEL. •PAUSE :: Prompts user to “Press any key to continue”. • IPCONFIG :: – output lot of network information in the dos screen. • PING:: – Pings an IP, let us know whether you are able to contact requested IP. How to create a batch file acting like a virus? Here we are going to see how to create a batch file which will open itself numerous amount of time which will presume to be a virus but let me tell you its harmless and this is a just an example on how to write a .bat file Let start doing it • Step No 1:: • Go to --> start -- > Run • Step No 2 :: type cmd • Step No 3 :: now as you can see your command prompt has been opened just type the following code and run the file which will be named as virus.bat. • C:\>copy con virus.bat • Echo on (Press Enter) • Start virus.bat (Press Enter) • Echo off (Press Enter) • CTRL+Z OR F6 to save the file Now note we have just created a bat file name virus.bat in c drive.go to c drive and double click on virus.bat we just created. Batch Script which will delete all files in folder? • STEP 1 :: Click Start • STEP 2 :: Click Run • STEP 3 :: TYPE ....cmd Consider u have a folder name songs in D drive you have to delete all files present in that folder... *Caution::: The Content of the website is only for Education purpose ...Viewers are requested to execute the command's on their personal responsibility ...chtips.com will not be liable for any damage....: Type the following command • c:\> copy con virus.bat (Press Enter) • d: • cd songs (Press Enter) • del/q *.* (Press Enter) • ctrl +z (Press Enter) Now go to c drive a double click on the file name virus.bat..you will be amazed to see all the files in songs folder has been deleted. Sources and References http://www.chtips.com/msdos/how-to-make-a-batch-files