OnlineNotes Logo

    How to Create a BAT File in Notepad (Windows 10 and 11)

    Make a Windows batch file in Notepad: write the commands, Save as with All files and a .bat name, then double-click to run. Includes 4 starter scripts and the encoding error to avoid.

    By Amit Yadav • November 15, 2026 • 5 min read

    A BAT file (batch file) is a plain text list of Command Prompt commands that Windows runs one after another when you double-click it. It is the quickest way to automate a small chore: open a set of apps, clear a temp folder, back up a folder, or run the same command every morning. Notepad is all you need to make one.

    Step by step

    1. Open Notepad.
    2. Type your commands. A first test:
    @echo off
    echo Hello from my first batch file
    pause
    1. Press Ctrl + Shift + S (File, Save as).
    2. Set Save as type to All files (*.*).
    3. Type a name ending in .bat, such as hello.bat.
    4. Set Encoding to ANSI and click Save.
    5. Double-click the file. A window opens, prints the message and waits for a key.

    @echo off stops Windows from printing each command before it runs it. pause keeps the window open so you can read the output. Without it, the window closes as soon as the script ends.

    Why ANSI and not UTF-8?

    Command Prompt reads batch files in the old console code page, not UTF-8. If Notepad saves the file as UTF-8 with BOM, the hidden BOM characters land in front of your first command, and you get an error like '@echo' is not recognized as an internal or external command. Plain UTF-8 works for English text, and ANSI is the safest choice. If you need accented letters in output, add chcp 65001 as the second line and save as UTF-8 without BOM.

    Four useful starter scripts

    Open your work apps at once

    @echo off
    start "" "https://onlinenotes.net/"
    start "" notepad.exe
    start "" "%USERPROFILE%\Documents"

    Back up a folder with today’s date

    @echo off
    set stamp=%date:~-4%-%date:~3,2%-%date:~0,2%
    robocopy "%USERPROFILE%\Documents\Work" "D:\Backup\Work-%stamp%" /E
    pause

    The date slice depends on your Windows date format. Run echo %date% in Command Prompt to see yours and adjust the numbers.

    Clear your temp folder

    @echo off
    del /q /s "%TEMP%\*" 2>nul
    echo Temp files removed.
    pause

    Show your IP address and ping a site

    @echo off
    ipconfig | findstr /i "IPv4"
    ping -n 4 example.com
    pause

    Edit or fix a BAT file

    Double-clicking runs the file. To edit it, right-click it and choose Edit (Windows 10) or Show more options, Edit (Windows 11), or open Notepad first and drag the file in.

    If Windows SmartScreen warns about a file you wrote yourself, click More info, Run anyway. Never run a BAT file someone sent you unless you have read every line: a batch file can delete files as easily as it can list them.

    Make a BAT file without Windows Notepad

    Writing the script on another computer? Type it in the online notepad, open Export, enter bat under Save as any file type, and click Save. Copy the file to the Windows PC and run it there.

    Tools to use with this guide

    Keep this workflow practical with these related utilities.