Recommended Free Tools
To create a batch file in Windows, write Command Prompt commands in a plain-text editor, save the file with a .bat extension, then run it from Command Prompt. A batch file is a text-based script for the Windows Command shell; it is not a PowerShell script, and changing a filename extension does not convert arbitrary text into valid commands.
What a Windows batch file does
A batch file contains commands that the Windows Command shell processes to automate routine tasks. Microsoft describes the Command shell as Windows’ original built-in shell for this purpose, including work such as account management and nightly backups. The Windows Commands reference covers Windows 10, Windows 11, and Windows Server versions: Microsoft Learn: Windows commands.
Command Prompt runs through cmd.exe. PowerShell is a separate Windows command-line shell with its own commands and syntax, so do not assume that a PowerShell cmdlet can be pasted into a .bat file. See Microsoft Learn: cmd.
Create a basic .bat file
-
Open Notepad or another plain-text editor. Enter these two lines, one command per line:
Recommended: Update Every Outdated Driver on Your PC in One Scan - Free →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.#1 Best Overall
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
@echo off echo Hello, world! -
Choose the editor’s Save As command and save the file as
hello.bat. The.batextension identifies a PC batch file, but an extension is only part of a filename—it does not turn non-batch content into a working script. Microsoft explains extensions in Common file name extensions in Windows. -
Check that Windows has not saved the file as
hello.bat.txt. In File Explorer, select View > Show > File name extensions to display full extensions, then inspect the filename.
Run the batch file and check its output
The clearest way to run a new script is from its folder in Command Prompt: that makes the command and console output visible if you need to troubleshoot.
Rank #2
- 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
- 4GB DDR4 System Memory; 128GB Solid State Drive
- 11.6" HD (1366 x 768) Multi-Touch Display
- Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
- Windows 11 Pro
-
Open the folder containing
hello.batin File Explorer.What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Open Command Prompt and change to that folder with
cd. For example, if the file is inC:Scripts, entercd /d C:Scripts. -
Enter
hello.batand press Enter. -
Confirm the console displays
Hello, world!.
You can also use the file’s normal open action in File Explorer, though how the window behaves depends on file associations and how Windows launches it. For explicit command execution, cmd.exe /c runs a command and exits; cmd.exe /k runs a command and keeps the interpreter open. Microsoft documents these switches in its cmd reference.
Rank #3
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
Understand the starter commands
-
@echo offstops batch commands from being echoed to the console, keeping output less cluttered. Microsoft’s echo reference explains the command and its use at the beginning of a batch file. -
echo Hello, world!displays the greeting. The same echo reference covers output and syntax.The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Common first-file problems
-
The file does not run as a batch script: show filename extensions in File Explorer and check that the actual name ends in
.bat, not.bat.txt.Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11- EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
- 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
- RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
- ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
- LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
-
The output is not what you expected: inspect each line for a valid Command Prompt command. A
.batextension does not make commands valid, and PowerShell-specific syntax is not automatically compatible. -
The window closes quickly: run the file from Command Prompt so you can see the execution and output in that console rather than relying on the file’s open behavior.
Only run batch files whose commands you understand, especially if they change or delete files or alter system settings.
Best Value
- WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
- 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
- 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
- CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
- LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
Build on the basics: variables and loops
Use a variable
The set command creates or changes an environment variable. In a batch file, references such as %NAME% substitute the variable’s value. See Microsoft Learn: set.
Use a for-loop variable
For a for loop, the variable syntax differs depending on where you type the command: an interactive Command Prompt example uses %f, while a batch file uses %%f. Using one percent sign in a batch file is a common copy-and-paste mistake. Microsoft documents the distinction in Microsoft Learn: for.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

