DOS Batch Files

.BAT is the file extension for batch files — plain-text files holding a series of commands that DOS (that’s Disk Operating System, for those who never booted a computer off a floppy disk) or the Windows Command Prompt executes in order, top to bottom. Starting programs, copying files, running utilities — anything you could type at a C:\> prompt, a batch file could do for you. Automatically. Every time. Without typos.

That last part is the whole point, and it’s why this site is called DotBat: at Commodore, I used these humble text files to automate an entire QA test bench. Do it once, do it right, let the machine do it forever.


Why bother in the 2020s?

Fair question. PowerShell exists. Python exists. And yet: every Windows machine on Earth still runs .bat files, no installation required, same as it did in 1985. There’s a lesson in that about simple tools that keep their promises — and honestly, some of us just like it.


The archive

The basics

  • Anatomy of a batch file: @ECHO OFF, comments, and why every script starts the same way
  • Variables and %1 %2 parameters
  • IF, GOTO, and the art of flow control before anyone said “flow control”

The classics

  • AUTOEXEC.BAT — the file that ran the world every morning
  • Menus with CHOICE
  • Loops with FOR — the most powerful three letters in DOS

Still useful today

  • Batch files for modern Windows housekeeping
  • When to graduate to PowerShell (and when not to bother)

Got a batch file war story, or a script that won’t behave? I have opinions about GOTO →