How to Create and Open Batch (BAT) Files on Windows 11

Aman is a Windows specialist and loves writing about the Windows ecosystem on Guiding Tech and MakeUseOf. He has a Bachelor’s in Information Technology and is now a full-time freelance writer with expertise in Windows, iOS, and browsers.

Afam has been a content writer with Guiding Tech Media since August 2023. However, his experience in tech writing dates back to 2018, when he worked as a freelance writer for Make Tech Easier. Over the years, he has grown a reputation for publishing quality guides, reviews, tips, and explainer articles. His work is featured on top websites, including Technical Ustad, Windows Report, and Next of Windows. He has training as a Microsoft Certified Professional and has covered more Microsoft-related guides on these platforms.

How to Create a Batch File (.Bat) on Windows 11

It’s easy to make a BAT file on Windows 11. You can use theNotepad appor any text editor on your Windows computer. Here’s a step-by-step instruction on how it’s done:

Step 1:Press theWindowskey to open the Start Menu.

Step 2:TypeNotepadin the search bar and pressEnter.

Step 3:Type the command below and pressEnterto proceed to the next line. This command disables the display for the entire script, so you don’t see it while it runs.

Step 4:Typetitleand write the title of your batch file. Then, pressEnter.

Step 5:Typeechoand the text you want to display on the output screen. Then, pressEnter.

Step 6:Typepauseand pressEnter. This indicates the end of the batch file and keeps the Command Prompt window open, which otherwise would have been closed once the command is successfully executed.

Step 7:Click theFileoption at the top left corner and chooseSave asfrom the context menu.

Step 8:Name the batch file and save it with theBATextension—for instance,hello.bat.

To run the batch file, head toward its location and double-click on it. A Command Prompt window will appear, 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 likefixing gpedit.msc missing error.

Open Batch 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. Here are some:

Method 1: Using the 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 theWindows+Ekeyboard shortcut to open the File Explorer.

Step 2:Click theViewbutton at the top and choosePreview pane.

Step 3:Head to thebatch file location.

Step 4:Click on thebatch fileto view its content in the preview pane.

Method 2: Opening With Notepad

While this process will work with any text editor, we show you how to use the built-in Notepad.

Step 1:Navigate to thelocationof the batch file.

Step 2:Right-click it and selectEdit in Notepad.

Method 3: Using Command-Line Tools

Command-line tools like Command Prompt andWindows PowerShelldisplay 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 thebatch fileand chooseCopy as pathfrom the context menu.

Step 2:Open theStart Menu, typeCommand Promptin the search bar, and chooseRun as administratorfrom the right pane.

Step 3:Typemore, followed by the copied path, and pressEnter. So, the command will look like this:

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 theStart Menu, typeWindows PowerShell, and chooseRun as administrator.

Step 3:Typeget-content, followed by the copied path, and pressEnter. So, the command will look this:

PowerShell will show the content of the batch file in the result.

Method 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.

Step 1:Navigate to thebatch file location, right-click on it, and chooseCopy as path.

Step 2:Open theStart Menu, typeGoogle Chrome, and pressEnter.

Step 3:Paste thecopied addressin the address bar and delete thedouble quotes. Then, pressEnter.

Google Chrome will display the batch file content.

Method 5: Using Microsoft PowerToys

Microsoft PowerToys helps power users to enhance their productivity. You can also use this tool to view the content of a batch file. You shoulddownload and installit, then continue with the steps below. Here’s how:

Step 1: Launch theStart Menu, typePowerToysin the search bar, and pressEnter.

Step 2:ChoosePeekfrom the left sidebar and toggle onEnable Peek.

Step 3:Click thePenicon next to Activation shortcut.

Step 4:Assign a shortcut key combination to trigger the peek feature. Ensure the shortcut starts withWindows,Alt, orShiftkey. Then, clickSave.

Step 5:Head to thelocationof the batch file.

Step 6:Click on thebatch fileand press thepeek feature key combination.

Was this helpful?

Last updated on 30 July, 2024

Leave a ReplyCancel reply

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

Name*

Email*

Comment*

Δ

The article above may contain affiliate links which help support Guiding Tech. The content remains unbiased and authentic and will never affect our editorial integrity.

More in Windows

4 Ways to Turn off Microsoft-Verified Apps in Windows 11

What Is Virtualization in Windows 10 and How to Enable It

JOIN THE NEWSLETTER

Get Guiding Tech articles delivered to your inbox.

© 2024 Guiding Tech Media. All Rights Reserved.