How to Write and Save Batch Files with Notepad

How to Write and Save Batch Files with Notepad

Introduction

Notepad is more powerful than most people think. It’s not only a text editor—it can also be used to create programs and automate tasks in Windows. One of the most popular uses of Notepad is writing batch files.

Thank you for reading this post, don't forget to subscribe!

A batch file is a script file in Windows that contains a series of commands. When you run it, Windows executes those commands one after another. This makes batch files very useful for automation, troubleshooting, and simple programming.

In this guide, we’ll show you step-by-step how to write and save batch files using Notepad.

What is a Batch File?

  • A batch file is a plain text file that contains commands for Windows Command Prompt (CMD).
  • It uses the .bat or .cmd file extension.
  • When you double-click it, the commands run automatically.

👉 Example use cases:

  • Automating backups
  • Running multiple programs at once
  • Displaying system information
  • Creating small utilities or pranks

Step 1: Open Notepad

  1. Press Windows + S.
  2. Type Notepad.
  3. Press Enter.

You now have a blank file to start writing your batch commands.

Step 2: Write Your First Batch Script

Here’s a very simple batch script:

@echo off
echo Hello, this is my first batch file!
pause

Explanation:

  • @echo off → Hides extra text so only your output is shown.
  • echo → Displays a message.
  • pause → Keeps the window open until you press a key.

Step 3: Save as a Batch File

  1. Click File > Save As.
  2. In the Save as type, select All Files.
  3. Name it something like firstscript.bat.
  4. Choose a location (like Desktop) and click Save.

Now you have created your first batch file.

Step 4: Run the Batch File

  • Go to the folder where you saved the file.
  • Double-click it.
  • A Command Prompt window will open and show:
Hello, this is my first batch file!
Press any key to continue . . .

👉 Congratulations! You just created and executed your first batch file Useful Batch File Example1. Open Multiple Websites at Once

@echo off
start https://www.google.com
start https://www.youtube.com
start https://notepadfree.site

👉 When you run this, your default browser will open all these websites instantly.

2. Launch Multiple Programs Together

@echo off
start notepad.exe
start calc.exe
start mspaint.exe

👉 This script will open Notepad, Calculator, and Paint at the same time.

3. Create a Simple Backup Script

@echo off
xcopy "C:\Users\YourName\Documents" "D:\Backup" /s /e /y
echo Backup completed!
pause

👉 This copies all files from your Documents folder to a Backup folder.

4. Show System Information

@echo off
systeminfo
pause

👉 Displays system details like OS, memory, and processor.

Shutdown or Restart PC

@echo off
shutdown -s -t 10 -c "Your PC will shut down in 10 seconds."

👉 This will shut down your PC in 10 seconds with a warning message.

Tips for Writing Batch Files

  • Always use .bat or .cmd extension.
  • Use REM to add comments (ignored by Windows).
    Example: REM This is a comment
  • If your script doesn’t work, open Command Prompt and run the file there to see errors.
  • Avoid dangerous commands unless you know what they do.

Advanced: Make Batch File Run Automatically

If you want your batch file to run at startup:

Conclusion

Batch files may look simple, but they are powerful tools for automation, customization, and productivity. With just Notepad, you can write scripts to open apps, backup data, or even control your system.

So next time you need a quick automation, remember—you don’t need expensive software. Just open Notepad, write a few lines, and save it as a .bat file.