Instructions for creating and using BAT file on Windows
TipsMake.com - Batch file (.bat) is a way to automate tasks on your computer automatically. You can automate everyday tasks, shorten the time needed to do certain things, and turn a complex process into something anyone can do. Since the program like AutoHotkey was born, many people didn't want to spend time writing or learning about .bat files, they didn't even know what it could do. But the benefits that the .bat files bring are still huge.
- Automate TELNET commands using VB Script
- Some tricks in Windows Scripting
Suppose you have frequent network problems, and always have to open the command prompt dialog box to enter commands like ipconfig , or Ping to Google to check the problem. Meanwhile, just a simple BAT file will make this work more efficient, you can also use this file for all other computers if you want.
In this article TipsMake.com will guide you how to create a simple batch file and some basic things about it. At the same time you will be provided with some resources for learning and writing batch files. Please consult!
Summary of article content Instructions for creating and using BAT file on Windows:
Step 1: Create BAT file
Step 2: Some basic code
Step 3: Some logic
Step 4: Write content for BAT file
Step 5: Run the newly created BAT file
Learn more about BAT file
Step 1: Create BAT file
First, create a new text document on your desktop (right click New > text document ). Double click to open this file, go to File > Save As . , in the Save As window, enter a name for the file and add the " .bat " extension (without quotes). The example we name is testBAT.bat .
Next, at Save as Type, select All Files (instead of Text Document (* .txt) ), click Save to save.
Step 2: Some basic code
If you already know how to run the command line in the command prompt, you will have a Wiz for creating BAT files because they have the same language. All you need to do is " talk " to the command prompt knowing that you want to place commands in the same file, instead of typing them every time you run the command prompt. This not only saves you time and effort, but also allows you to include some logic (such as a simple loop, conditional statements .) that are programmable in terms of face concept.
Here are 7 simple commands that you should know:
- TITLE : window name for BAT file.
- ECHO : Print command of BAT file. Anything after ECHO will be displayed in the command prompt (like text) on each line.
- ECHO OFF : This command is usually placed on the top of the BAT file. When running the BAT file with this command, the commands below ECHO OFF will not be displayed (ie only content, no command will be used).
- PAUSE : when using this command, a message saying "press any key to continue ." will display on the screen, the entire command in the BAT file will be paused until you press any key to restart. This way you will have a chance to see what's happening on the screen.
- CLS : clean DOS window screens (very useful when they become dense and messy).
- IPCONFIG : information about the network displayed on DOS (very useful for network administrators).
- PING : ping to the IP address, indicating whether you can contact the computer or not. This command also returns the ping time and will default to ping 3 times.
Step 3: Some logic
We need to plan our program. Any good programmer thinks about the general framework of work before conducting dashes on what needs to be done. This helps prevent logical mistakes that are difficult to make.
For the program in this article, we need to check the computer network and internet settings with the command ' ipconfig / all ', then review the information. Finally ping google.com to find out if we really have internet access. If everything is fine, we will pause the program.
Step 4: Write content for BAT file
To edit the content for the .bat file, right-click it and select ' edit '. The BAT file will be opened with the Notepad editor, here you will see a blank page and ready for us to enter content there.
(Each command will have a comment line in the form CODE :: Comment, with the bold part being the command we use).
ECHO OFF
:: CMD will not work properly.
ECHO QuanTangMang: Demo a BAT file
:: Print the board
IPCONFIG / ALL
:: Show test information on the command prompt
PAUSE
:: The content of the test is used to view important information.
PING www.google.com
:: Ping to Google.com
ECHO Information on Google Ping.
:: Print the board
PAUSE
:: Give users the content to view. The command is on the same day after the movie has started, so the command will continue.
Step 5: Run the newly created BAT file
After inserting the internal file for the BAT file, save and then double-click it to run the bat file. The screen will show the following result:
So you succeeded!
If you want to edit the BAT file, open the BAT file with Notepad by right-clicking on the BAT file, selecting Open with> Notepad.
Learn more about BAT file
If you want to learn more about BAT files, you can see the commands available here. You can then write your own programs or refer to the examples available here.
Using BAT files is a really useful solution to run programs (such as Java) with just one command line, saving you time instead of typing the command line from the beginning. After understanding how it works and its commands, users can easily create files for their own work quickly.
You can try These hack tips are only Notepad can do to get a better understanding of how to create a .bat file and just relax.
See more:
- How to create Keylogger with Notepad
- How to create a blue screen of death (BSOD) to "prank" friends
- Troll friends by creating "fake" virus on Notepad
You should read it
May be interested
- What is HDMI? What is HDMI used for?hdmi is a popular cable used in modern electronic devices, from pc, mac, computer monitor, control panel, bluray head. but what does it do? and why is it so popular?
- Guide to finding the same photo with TinEyein the previous article, tipsmake.com introduced you how to find the same photos using google image, and this time we will continue with the article about tineye - online service to help users find their photos (or almost the same) from the internet.
- Useful applications for studentsgoodbye to the exciting summer vacation, the students and students all over the country started a new school year full of tension and competition. today, we would like to synthesize some applications or mobile phones to better serve your learning.
- Video tutorial for creating adhoc wifi on Windows 7wifi adhoc - a concept that is both familiar and popular for many computer users, but in fact, not everyone knows how to create wifi hotspot based on their laptop.
- How to enable or disable 3G on Windows Phone?in the article below, we will show you how to enable or disable 3g on your lumia phone, as the example here i am using microsoft's lumia 920. the use of 3g is becoming more and more popular and widespread, due to the inevitable development of technology, user requirements ... and a smartphone like lumia that satisfies those needs very well.
- So choose a computer, laptop how to fit?the new school year has begun, students and students are eager to enter the school, and accompanied by the need to use computers as a tool to support indispensable learning and research. today, tipsmake.com will introduce, share with you some useful experiences when choosing to buy a computer to suit your needs!