Table of Contents
Batch files are a versatile tool used to automate daily tasks, streamline processes, and simplify complex operations into user-friendly actions that anyone can execute.

In this article, you’ll learn how to write a simple batch file, explore the basics of what batch files can do, and discover how to create them yourself. Additionally, I’ll provide resources to help you further develop your skills in writing batch (BAT) files.
How to Create a Batch File on Windows
To create a Windows batch file, follow these steps:
1. Open or create a new text file using Notepad or WordPad document or any text editor.

2. Add your commands:
- @echo off : This parameter will allow you to view your working script in the command prompt. This parameter is useful for viewing your working code. If any issues arise from the batch file, you will be able to view the issues associated with your script using the echo function. Adding a following off to this parameter will allow you to quickly close your script after it has finished.
- title This is your first batch script: Providing much of the same function as a <title> tag in HTML, this will provide a title for your batch script in your Command Prompt window.
- echo Welcome to batch scripting: Print “Welcome to batch scripting”
- pause: Allows a break in the logical chain of your BAT file. This allows for users to read over command lines before proceeding with the code. The phrase “Press any key to continue…” will denote a pause.
@echo off
title This is your first batch script.
echo Welcome to batch scripting.
pause

3. Next, save your text file with the .bat file extension by navigating to the File menu and selecting Save As... option.

4. In the Save As window, change Save as type to All Files then type a filename with .bat as the file extension.

5. Now, double-click on your newly created batch file to run it.

And here’s the corresponding command window for the example above:

6. To edit the batch script, let’s right click on it then select Edit.
Basics of Batch Scripting
Batch files use the same language as the Command Prompt, but instead of typing commands manually, you input them into a file, saving time and effort. They also allow for basic logic, such as loops, conditional statements, and other procedural programming concepts.
More basic parameters for batch scripting:
- cls: Clears your command prompt, best used when extraneous code can make what you’re accessing had to find.
- rem: Shorthand for remark provides the same functionality as <!– tag in HTML. Rem statements are not entered into your code. Instead, they are used to explain and give information regarding the code.
- %%a: Each file in the folder.
- (“.\”): The root folder. When using the command prompt, one must direct the prompt to a particular directory before changing a files name, deleting a file, and so on. With batch files, you only need to paste your BAT file into the directory of your choosing.
The library for batch variables is huge, to say the least. Luckily there is a Wikibook entry that holds the extensive library of batch script parameters and variables at your disposal.
Examples of batch scripts
In this section, we’ll create examples of batch scripts designed to streamline and simplify your daily online and offline tasks.
The script below uses multiple start “” parameters to open several websites in separate tabs through a batch file. Simply replace the provided links with your desired URLs.
@echo off
start "" http://www.bbc.com
start "" https://google.com/
start "" https://bonguides.com/

Batch file that opens multiple programs
If you frequently open the same set of applications, you can create a custom launcher batch file to open multiple programs simultaneously with just one click.
All you need is the file location of each program. For example, if you need to open Excel, Calculator, and Microsoft Edge, use the following code snippet:
@echo off
cd "C:\Program Files\Microsoft Office\root\Office16\"
start excel.exe
start calc.exe
cd "C:\Program Files (x86)\Microsoft\Edge\Application"
start msedge.exe

Batch file to restart your computer
The below script will restart your computer after 5 seconds.
@echo off
shutdown -r -t 5

Conclusion
This is just a glimpse of what batch scripts can do. Whether it’s organizing files, opening multiple web pages, renaming files in bulk, or creating backups of important documents, batch scripts can simplify repetitive tasks and save you time and effort.