• 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.
  • You need a text editor like Notepad to create batch files on Windows 11.
  • You can view batch files using different native features of Windows 11, including Notepad, Command Prompt, and your browser.

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

It’s easy to make a BAT file on Windows 11. You can use the Notepad app 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 .

Typing Notepad in Windows Search - 1

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

@echo off
echo off command in notepad - 2

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

title command in notepad - 3

Step 5: Type echo and the text you want to display on the output screen. Then, press Enter .

echo command in notepad - 4

Step 6: Type pause and press Enter . 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.

pause command in notepad - 5

Step 7: Click the File option at the top left corner and choose Save as from the context menu.

Save as option in notepad - 6

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

File name of the batch file - 7

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.

batch file result in CMD - 8

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 .

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 the Windows + E keyboard shortcut to open the File Explorer.

Step 2: Click the View button at the top and choose Preview pane .

Preview pane option in File Explorer - 9

Step 3: Head to the batch file location .

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

Content on Preview pane in File Explorer - 10

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 the location of the batch file.

Step 2: Right-click it and select Edit in Notepad .

Edit with Notepad - 11

Method 3: 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 Copy as path from the context menu.

Copy as path option in context menu - 12

Step 2: Open the Start Menu , type Command Prompt in the search bar, and choose Run as administrator from the right pane.

Command Prompt in Start Menu - 13

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

more “copied path”
more command in cmd - 14

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

batch file result using more command in CMD  - 15

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 Run as administrator .

Accessing Windows PowerShell in to Create and View Batch Files (BAT) on Windows 11 - 16

Step 3: Type get-content , followed by the copied path, and press Enter . So, the command will look this:

get-content “copied path”
get content command in PowerShell - 17

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

batch file result using get content command in PowerShell - 18

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 the batch file location , right-click on it, and choose Copy as path .

Copy as path option in context menu - 19

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

Typing Google Chrome in Start menu - 20

Step 3: Paste the copied address in the address bar and delete the double quotes . Then, press Enter .

Typing batch address in chrome - 21

Google Chrome will display the batch file content.

viewing batch file result in chrome - 22

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 should download and install it, then continue with the steps below. Here’s how:

Step 1 : Launch the Start Menu , type PowerToys in the search bar, and press Enter .

Typing Microsoft PowerToys in Start menu - 23

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

Enable Peek toggle in PowerToys - 24

Step 3: Click the Pen icon next to Activation shortcut.

Pen icon in PowerToys - 25

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

Activation shortcut option in PowerToys - 26

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

Step 6: Click on the batch file and press the peek feature key combination .

peek window showing batch file content - 27

Was this helpful?