I graduated in Mechanical Engineering.
So I do not know: Why bat files are used? How are they created?
Hence I thought of writing below post.
BATCH file is way of getting things done on any computer.
These files mainly automate everyday tasks to save time.
Step 1.Create blank text file on your computer.
Step 2.Rename it as test.bat
I assume you know how to run commands from Command Prompt.
We type command in cmd prompt and run whenever we want. Instead typing on our own these commands are put in .bat file to get executed.
It has 2 main benefits -
1. To implement your own logic
2. To save time.
Also,Commands are not CASE Sensitive.
Let us understand some basic commands -
TITLE - used for displaying title of command window.
ECHO - This is print statement of .bat file.
Anything following the word ECHO will be displayed in the command prompt as text.
ECHO OFF –It means that the program won’t show the command that you told it to run while it’s running – it’ll just run the command.
PAUSE – This outputs the “press any key to continue…” message.
It’s helpful because it pauses the BAT file execution until the user tells it to go again. If you don’t put this in your program, everything will speed by and end before you can see it.
CLS – Clears the command window.
IPCONFIG -gives network information about your connected machine.
PING - To check if any machine can be contacted.
Let us write program to check the computer’s network/internet settings with an “ipconfig /all” command, and then review that info. Afterwards, we want to ping google.com to figure out if we really truly have access to the internet. We’ll pause the program after this as well, because we want to know for sure that they saw it.
Step 3. Open created test.bat in notepad.
Step 4. Write below steps to in it.
TITLE TEST BAT FILE
::Add Title to command window.
ECHO OFF ::CMD will no longer show us what command it’s executing(cleaner) ECHO THIS IS PRINT :: Print some text IPCONFIG /ALL :: Outputs tons of network information into the command prompt PAUSE :: Lets the user read the important network information PING www.google.com :: Ping google to figure out if we’ve got internet! ECHO All done pinging Google. ::Print some text PAUSE :: Give the user some time to see the results. Because this is our last line, the program will exit and the command window will close once this line finishes.
Step 5.
Open your command prompt.
Navigate to folder where test.bat is located.
then use command "test.bat" and it will run successfully.
Output:
Hope this will help you.
So I do not know: Why bat files are used? How are they created?
Hence I thought of writing below post.
BATCH file is way of getting things done on any computer.
These files mainly automate everyday tasks to save time.
Step 1.Create blank text file on your computer.
Step 2.Rename it as test.bat
I assume you know how to run commands from Command Prompt.
We type command in cmd prompt and run whenever we want. Instead typing on our own these commands are put in .bat file to get executed.
It has 2 main benefits -
1. To implement your own logic
2. To save time.
Also,Commands are not CASE Sensitive.
Let us understand some basic commands -
TITLE - used for displaying title of command window.
ECHO - This is print statement of .bat file.
Anything following the word ECHO will be displayed in the command prompt as text.
ECHO OFF –It means that the program won’t show the command that you told it to run while it’s running – it’ll just run the command.
PAUSE – This outputs the “press any key to continue…” message.
It’s helpful because it pauses the BAT file execution until the user tells it to go again. If you don’t put this in your program, everything will speed by and end before you can see it.
CLS – Clears the command window.
IPCONFIG -gives network information about your connected machine.
PING - To check if any machine can be contacted.
Let us write program to check the computer’s network/internet settings with an “ipconfig /all” command, and then review that info. Afterwards, we want to ping google.com to figure out if we really truly have access to the internet. We’ll pause the program after this as well, because we want to know for sure that they saw it.
Step 3. Open created test.bat in notepad.
Step 4. Write below steps to in it.
TITLE TEST BAT FILE
::Add Title to command window.
ECHO OFF ::CMD will no longer show us what command it’s executing(cleaner) ECHO THIS IS PRINT :: Print some text IPCONFIG /ALL :: Outputs tons of network information into the command prompt PAUSE :: Lets the user read the important network information PING www.google.com :: Ping google to figure out if we’ve got internet! ECHO All done pinging Google. ::Print some text PAUSE :: Give the user some time to see the results. Because this is our last line, the program will exit and the command window will close once this line finishes.
Step 5.
Open your command prompt.
Navigate to folder where test.bat is located.
then use command "test.bat" and it will run successfully.
Output:
Hope this will help you.