A batch file contains a series of DOS commands and is commonly used to automate frequently performed various tasks. It makes the life as just save your commands in one file and double click on it from your Windows machine.
- Create a .bat file Create a .txt document file in your Windows desktop. Open the file and save as test.bat(without quotes), you can see the icon changed from .txt to something else.
- Add some code to execute
Learn some simple command to execute
ECHO – Just do the same as print function
PAUSE – This outputs the “press any key to continue”, it’s better you add this line after an execution, otherwise, everything will execute so fast and closes the window, so you don’t know what’s happening. This will ask your input before closing the window. Next, open your test.bat and add below lines to it
ECHO “hello man”
PAUSE - Run your .bat file Just double click on your .bat file, it will pop up the windows cmd.exe and display all the outputs.
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply