What Is a Batch Script?
A Batch script is a simple text file with commands that Windows executes in the Command Prompt. It's one of the easiest ways to automate tasks such as deleting files, opening programs, checking system info, and much more.
Your First “Hello World” Batch Program
Let's create your first working script. Every language starts with “Hello World”. In Batch, it's extremely simple.
@echo off
echo Hello World!
pause
Explanation:
@echo off→ hides command execution linesecho Hello World!→ prints text on screenpause→ waits for a key press so the window doesn't close instantly
How to Create the Script
Follow these steps:
- Open Notepad
- Paste the script above
- Click File → Save As
- Set file type to All Files
- Save it as hello.bat
Double-click the file — boom. You just created your first Batch script.
Running Commands
Batch lets you use all normal Windows console commands. Try this script:
@echo off
echo Showing system info...
systeminfo
pause
This prints detailed system information directly from Windows.
Cleaning Temporary Files (Useful Example)
@echo off
echo Cleaning temporary files...
del /q /f "%TEMP%\*"
echo Done!
pause
This deletes all temporary files in the Windows temp folder. Super useful for quick performance cleanup scripts.
What's Next?
In the next tutorial, we jump into Python and write your first Python script. After that, we return to Batch for variables, loops, arguments, and automation.