You are on page 1of 23

Guiding

Tech  Tips, tricks, buying guides & more…

How to Create and


View Batch Files
(BAT) on Windows 11
By Aman Kumar Published August 4, 2023

While Windows makes it easy to install and remove


programs, some of them require complex steps to be
under taken in PowerShell or Command Prompt.
Whether you enjoy using the Command Prompt or
not, a compilation of commands can automate tasks
and make your work easy. With that, you can boost
your productivity.

DID YOU KNOW


The world’s first color photo
was made in 1861 by the
three-color method.
If you need to perform a repetitive task on your
computer, you can create a batch file for it. But what
precisely is a batch file? We will see what a batch
file is and when you should use it. We will also
explain how to create and view batch files (BAT) on
Windows 11. So, let’s begin.
×

Guiding Tech Latest Videos


More in Windows

WHAT IS A BATCH FILE?


A batch file is an automated script containing a
sequence of commands executed in serial order and
these commands don’t require user input, unless
specified. Any file with a .BAT extension on your
The Complete Guide to Setting
computer is typically a batch file. Up Parental Controls In
Windows
A batch file is written using a simple scripting
language that contains commands, loops,
conditionals, and other structures. You can make a
.BAT file using Notepad or any other text editor.

How to Get Rid Of Widgets on


Windows 11

×
The batch files are beneficial for repetitive tasks such
as opening programs and executing operations like JOIN THE NEWSLETTER
copying or deleting files. However, there are many
Get Guiding Tech articles
more scenarios where you can use a batch file. Let’s
check them out. delivered to your inbox.

You can use a batch file to change your computer Your email address
settings. For instance, you can execute a batch file
to sideload tools at once, that don’t come pre-
SUBSCRIBE
installed on Windows.

A batch file can help you create a specific


environment required for developing a software
project.

You can write a batch file to instruct the computer


about the order and dependencies of commands.
This ensures that all the commands are executed
correctly with no or least intervention.

You can use a batch file to create backup and


transfer data between directories. For instance,
you can create and run a batch file to copy files
from one location to another.

A batch file can be used along with the Windows


Task Scheduler to automate tasks at a particular
time.

THINGS TO KEEP IN MIND WHEN


RUNNING A BATCH FILE ×
There are various aspects you must consider when
running a batch file. Neglecting them can make your
system unstable and cause different error codes.

You’ll need to sure that you run the batch file from
the correct directory. An incorrect file path or
directory can lead to unexpected computer
behavior or errors.

A batch file is executed line by line, meaning any


typo or missing command can render the entire
script useless. So, make sure all the BAT file
commands are in correct order.

When it comes to making system changes, a batch


file requires administrative permissions. So, ensure
you have admin rights on the computer.

As a batch file can modify system settings, so


you’ll need to handle them properly and protect
them from getting into the hands of any malicious
agents.

Unlike other Windows applications, a batch file


doesn’t have an error reporting mechanism. If a
batch file fails to execute, you will have to go
through all the commands in it one by one to spot
the error.

Now that you know a bit about batch files, let’s check
out how to create a view batch file (.BAT) on
Windows 11.
×
HOW TO CREATE A BATCH SCRIPT
FILE (.BAT) ON WINDOWS 11
It’s very easy to make a BAT file on Windows 11.
You can take help of the Notepad or any text editor
on your Windows computer. Here’s a step-by-step
instruction on how it’s done:

Step 1: Press the Windows key to open the Start


Menu.

Step 2: Type Notepad in the search bar and press


Enter.

Step 3: Type @echo off and press Enter to move to


the next line. This command disables the display for
the entire script – that means you don’t see the script
while it runs.

×
Step 4: Type title and then write the title of your
batch file. Then, press Enter.

Step 5: Type echo and type the text you want to


display on the output screen. After that, press Enter.

Step 6: Type pause and press Enter. This indicates


the end of the batch file. It also keeps the Command
Prompt window open, which otherwise would have
been closed once the command is successfully
executed.
×
Step 7: Click the File option at the top left corner and
choose Save as from the context menu.

Step 8: Give a proper name to the batch file and


save it with BAT extension—for instance, hello.bat.

×
To run the batch file, head toward the batch file
location and double-click on it. A Command Prompt
window will crop up, showing the output of the
batch file.

The above was a simple example of a batch file.


Similarly, you can create and run a batch file to
perform more complex operations like fixing
gpedit.msc missing error.

HOW TO VIEW A BATCH SCRIPT


FILE (.BAT) ON WINDOWS 11
There may be situations when you want to view the
content of the batch file. It may be because you are
×
suspicious about the file or want to edit its content.
Fortunately, various ways to view a batch file on
Windows 11 exist. Of course, you can open any
batch file using the Notepad app. But viewing a long
list of commands can be tedious and leaving a typo
in there can ruin the batch file. Let’s check out the
most convenient ways to preview a .BAT file.

1. Using File Explorer

The quickest way to view a batch file’s content is


through the Windows File Explorer preview option.
Here’s how to enable this option and view a batch
file using it:

Step 1: Press the Windows + E keyboard shortcut to


open the File Explorer.

Step 2: Click the View button at the top and choose


the Preview pane.

Step 3: Head to the batch file location.

Step 4: Click on the batch file to view its content in


the preview pane.

×
2. Using Command-Line Tools

Command-line tools like Command Prompt and


Windows PowerShell display the output of a batch
file and its content. Here’s how to use Command
Prompt to view a batch file:

Step 1: Right-click on the batch file and choose the


‘Copy as path’ option from the context menu.

Step 2: Open the Start Menu, type Command


Prompt in the search bar, and choose ‘Run as
administrator’ from the right pane.

×
Step 3: Type more followed by the copied path and
press Enter. So, the command will look like this:

more “copied path”

You’ll see the batch file content in the result.

×
To view a batch file using PowerShell, follow these
steps:

Step 1: Copy the path of the batch file using the


steps mentioned above.

Step 2: Launch the Start Menu, type Windows


PowerShell, and choose the ‘Run as administrator’
option.

Step 3: Type get-content followed by the copied


path and then press Enter. So, the command will ×
look this:
get-content “copied path”

PowerShell will show the content of the batch file in


the result.

3. Using Microsoft PowerToys

Microsoft PowerToys is a great tool that helps power


users to enhance their productivity. You can also use
this tool to view the content of a batch file. Here’s
how:

Step 1: Launch the Start Menu, type PowerToys in


the search bar, and press Enter.

×
Step 2: Choose Peek from the left sidebar and turn
on the Enable Peek toggle.

Step 3: Click the Pen icon next to the Activation


shortcut option.

×
Step 4: Assign a shortcut key combination to trigger
the peek feature. Make sure the shortcut starts with
Windows, Alt, or Shift key. Then, click Save.

Step 5: Head towards the location of the batch file.

Step 6: Click on the batch file and press the peek


feature key combination.

4. Using a Browser

You can use your favorite browser to view the


content of a batch file. Below are the steps to view
batch files using Google Chrome. The steps will be
similar for any other browser.

Step 1: Navigate towards the batch file location,


right-click on it, and choose the ‘Copy as path’ option.

×
Step 2: Open the Start Menu, type Google Chrome
and press Enter.

Step 3: Paste the copied address in the address bar


and delete the double quotes from it. Then, press
Enter.

×
Google Chrome will display the batch file content.

EVERYTHING ABOUT BATCH


FILES

Whether you want to perform a repetitive task or


automate a process, you can use a batch file.
However, what if you want to ensure the safety of
the file before executing it? You can do that by
viewing the content of the batch file using the above
methods.

Last updated on 10 July, 2023


The above article may contain affiliate links which help support
Guiding Tech. However, it does not affect our editorial integrity. The
content remains unbiased and authentic.

Read Next

×
Sachin Saga Warm Up: Bat as Sachin
Tendulkar
Playizzon, an India-based mobile game
making company, has released a
cricket game — Sachin Saga Warm Up
— which borrows Sachin Tendulkar’s
techniques to play the game as well as

4 Easy Ways to Batch Rename Files on


Windows 11
Have multiple files that need to be
renamed for file keeping?

×
How To Efficiently Batch Rename Files
Using Personal Renamer
Let’s say you transfer a photograph
from your Sony digital camera to the
computer.

How to Batch Rename Files in Adobe


Lightroom
Adobe Lightroom is a great tool for
editing your photos and giving them a
more professional touch.

×
How to Easily Batch Rename Files in
Mac OS X Yosemite
I’m sure there are hundreds of
unorganized files on your Mac right
now.

Batch Install, Update, Uninstall


Windows Programs With FreeApps
In the past, we have covered three
amazing tools using which you can
easily manage your free programs on
Windows.

×
Batch Uninstall Windows 8 Apps
Silently in Background
Every once in a while I do a bit of
spring cleaning on my computer and
that’s when I delete old files and
uninstall old programs.

How to Batch Uninstall Windows


Programs with IObit Uninstaller 2
Being a technology blogger, I have to
install a countless number of
applications on my system for
reviewing, but I don’t uninstall them
right away.

WRITTEN BY

Aman
SHARE ON
Kumar
Aman is a Windows
specialist and loves writing
JOIN THE NEWSLETTER
about the Windows
ecosystem on Guiding Tech
×
and MakeUseOf. He has a
Bachelor's in Information
Technology and is now a full-
Your email address SUBSCRIBE
time freelance writer with
expertise in Windows, iOS,
and browsers.

Leave a Reply
Name * Email *

Comment *

Post Comment

×
#Android #How-tos Facebook Guiding
#Windows #Comparisons Instagram
Tech
#Internet and Social #Tips & Tricks Instagram (Intl) About
#iOS YouTube Contact
#Gadgets YouTube (Intl) Terms of Use
#Mac Twitter Privacy Policy
#Buying Guides Twitter (Intl)

Advertise

© 2023 Guiding
Tech Media. All
Rights Reserved.

Information from your device can be used to personalize your ad experience.

Do not sell or share my personal information.

You might also like