Instructions for creating and using BAT file on Windows

How to create a simple batch file and some basics about it will be presented in this article. At the same time you will be provided with some resources for learning and writing batch files.

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.

  1. Automate TELNET commands using VB Script
  2. 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.

Picture 1 of Instructions for creating and using BAT file on Windows

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:

  1. TITLE : window name for BAT file.
  2. ECHO : Print command of BAT file. Anything after ECHO will be displayed in the command prompt (like text) on each line.
  3. 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).
  4. 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.
  5. CLS : clean DOS window screens (very useful when they become dense and messy).
  6. IPCONFIG : information about the network displayed on DOS (very useful for network administrators).
  7. 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:

Picture 2 of Instructions for creating and using BAT file on Windows

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:

  1. How to create Keylogger with Notepad
  2. How to create a blue screen of death (BSOD) to "prank" friends
  3. Troll friends by creating "fake" virus on Notepad
Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile