How to create batch file in Windows? Easy method to create .BAT file in Windows in 3 steps!

Published: Last Updated on 893 views 6 minutes read
A+A-
Reset

How to create Batch File in Windows without using any third-party tool? We will try to answer this question in this article and learn creating .BAT file easily to perform some regular task or create script for performing system task.

What is batch (.BAT) file in Windows?

A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file.

Wikipedia definition

If we have to describe the above definition more specifically with example, let’s consider below example.

Batch File with Example – Commands with Explanation

You have to create a new folder named “DotNetGuide” inside D partition of your Hard-disk and then create a Readme.txt file inside that directory using command mode, you would write command lines multiple times and below would be sequence of instruction.

  1. Go to D Drive Partition (d:)
  2. Create New folder with name DotNetGuide. (md DotNetGuide) – Read guide on how to create folder in MS-DOS.
  3. navigate to newly create folder (cd DotNetGuide)
  4. start creating new Readme.txt file (copy con Readme.txt ….) – Read guide on how to create file in MS-DOS.

Create Batch File (Step by Step method)

Let’s write down all instructions in single file at once and save it as batch file.

Step 1: Open Notepad or any of your favorite Text Editor.

Few years ago, actually many years ago, I created below presentation aimed at beginners. This includes how to open Notepad to other basic operations.

Step 2: Write command lines in sequence

In this example, I am trying to create a virtual Wi-Fi hotspot from my laptop. We have covered this in article How to Create Hotspot from your Windows?

NETSH WLAN SET HOSTEDNETWORK MODE=allow SSID=john KEY=john1234
NETSH WLAN START HOSTEDNETWORK

Step 3: Saving the file as .BAT (Important)

Create Batch file from Windows (BAT file from Windows)

When you have completed putting your commands in sequence, now time is to save file. Look carefully at below image first. You have to give the file extension (.BAT) and Select Save as type to All Files (*.*) to create batch file. Everything is depended on this step, if you don’t choose file’s extension as BAT, your file will be saved as normal Text file with .txt extension and that won’t execute itself.

We have tried to simply create batch file in Windows with bare minimum requirement and safe to execute code. There is vast use of batch script and extensive coding skills required. Read detailed documentation about echo command which is most used in batch files.

Let’s have a look at desktop, there should be new file with HotSpot.bat and its extension will be different from normal files.

Create Batch file with Windows, BATCH File ICON & Extra tools in Explorer

As you see, BAT file are executable command file and they need not to be installed. Also, you can see additional menu in Windows Explorer that shows Application Tools like Run as Administrator and Pin to Taskbar.

Warning: Do not execute untrusted batch files

Serious Warning: BATCH File has capability to change system files and may harm operating system. Most of the hackers’ attack system using .BAT files in email attachments of downloads. Some viruses even create BAT file of every folder and file and trick user to install untrusted code in computer. Do not try to create batch file unless you understand what you are doing.

BAT Files command can be checked by clicking Open with option and choosing Notepad. Notepad can display what is inside the .BAT script file and you can take decision. Do not open and click batch files from untrusted source.

Related Posts

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Index

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.