What is a batch file?

A. A batch file is a text file with a .bat or .cmd extension. A batch file adheres to a syntax and a set of valid commands or instructions. To run a batch file, enter the file’s name. You don't need to enter the .cmd or .bat extension. To write a basic batch file, perform the following steps.

@echo hello world

@echo off

@echo off
  1. Open Notepad.
  2. Enter the command
  3. Text that follows the echo command will output to the screen. The @ symbol suppresses the command from printing to the screen. To prevent commands from displaying for an entire batch file, enter
  4. at the top of the batch file.
  5. Select Save As from the file menu.
  6. Enter the batch file’s name as
  7. Be sure to enter the name in quotes, or Notepad will add .txt to the end.
  8. Run cmd.exe to start a command session.
  9. Enter the batch file’s name, without the extension.
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.