How To Create And Run Batch Script File On Windows 11?

A Batch file is a complex file created on Windows OS that helps users to carry out repetitive tasks with one or two mouse clicks. For example, if you wish to clear the temp and junk files of your PC every week, then you have to navigate to some specific folders and select the files and delete them. But this consumes time and effort and we might even skip doing this sometimes. If you create a Batch file on Windows, then you need to run that file by double-clicking on it and it will automatically delete all the contents of the folders mentioned in the file.

There are many other tasks you can shorten or automate by creating Batch files. So without further ado, let us explore the world of Windows Batch Script and create a few to make life easier.

Also Read: How To Run Batch File As Administrator On Windows 10

How To Create An Empty Batch Script File On Windows PC?

First, we will explore the steps to create a basic Batch Script File format that can be used to create other bat files by adding or modifying text within.

Step 1: Open the Notepad app on your PC.

Step 2: Add the following command in the notepad file:

@echo off

Title [Write the title of your Batch Script]

Echo

Pause

Step 3: Click on the File tab and choose Save As from the drop-down menu. Enter the file name followed by “.bat”. Also, choose the location where you wish to save this file from the section above.

Step 4: In the save as type box, choose All Files and click on the Save button.

notepad command

Step 5: Make double-click on the Bat file you just created and it will execute. You can also right-click on it and select Open.

select Open

Step 6: If you wish to edit this Bat file then you can make right-click on the file and select Edit from the context menu.

Edit from the context menu

Here is an example of a basic bat file that you can start with.

test bat fileOnce you run this batch file, this is what you will see.

cmd

Please don’t get disappointed by the end result just yet. You need to understand that the first batch script we created had only four lines including the opening, the closing line, and the Title. The only command line in this script was “Echo” which means to display something and that is what this Batch file just did.

Also read: Know All About Batch File

Some Examples Of Useful Batch Files That You Can Create

Now that you know how to create and run a Batch script file, let us check a few examples of some useful batch files that you can actually create. Remember, a batch file uses the same command as the Command Prompt, without having to open the Command Prompt app.

Example 1: Open Multiple Websites With A Double-Click

If the first thing you do every morning is to open a few websites on news, stocks, gossip, YouTube, etc. then you can reduce the task effort by creating a Bat file. Instead of clicking on website shortcuts on your desktop or opening each website in the browser by typing its address, you can reduce the task to a double click on a batch script file. Here is the batch file:

@echo off

cd “” https://wethegeek.com/

start “” https://www.youtube.com/

start “” https://www.google.com/

start “” https://www.eonline.com/news

start “” https://www.sportsgossip.com/

start “” https://www.washingtontimes.com/

start “” https://www.thetimes.co.uk/

Note: You need to copy and paste the above lines in a Bat file and execute it by double-clicking on it. All the websites listed in the command will open in different tabs of one browser window of your default browser.

You need to change the websites according to your needs. Remember to delete the websites mentioned from “Http” and click on the address bar of the website you wish to add and copy and then paste the address after Start””.

Example 2: Launch Multiple Programs

If there are a few apps that you regularly use and want to open all of them in one go, here is a batch script file for that. I have mentioned 3 apps namely Calculator, Command Prompt, and MS Word as I use these apps quite frequently. You can mention any number of apps of your own choice.

@echo off

cd “C:\Windows\System32”

Start calc.exe

cd “C:\Windows\System32”

Start cmd.exe

cd “C:\Program Files\Microsoft Office\root\Office16\”

start Winword.exe

start Winword exe

Note: You need to specify the path of the executable file of the app you wish to open in the first line beginning with “cd”. And then mention the name of the executable file after “Start” to launch the app.

The Final Word On How To Create And Run Batch Script File On Windows 11?

It is not easy to create an advanced batch file. You need to know what command would work and how to place them in the bat file. You also need to research and gather information from Google and other sources. Once you successfully create a batch file, you are going to enjoy using it as it reduces the time and effort required to do everyday’s tasks.

Please let us know in the comments below if you have any questions or recommendations. We would be delighted to provide you with a resolution. We frequently publish advice, tricks, and solutions to common tech-related problems. You can also find us on Facebook, Twitter, YouTube, Instagram, Flipboard, and Pinterest.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe Now & Never Miss The Latest Tech Updates!

Enter your e-mail address and click the Subscribe button to receive great content and coupon codes for amazing discounts.

Don't Miss Out. Complete the subscription Now.