Batch File Extensions

Maintained on

By utilizing Command Prompt, you can execute specific operations on your computer from the command line.

While you can directly input and execute commands from Command Prompt, creating batch files is effective for executing multiple commands together.

You can write a series of commands that run on Command Prompt and execute them all at once by double-clicking or running them from Command Prompt.

Batch file extensions come in two types: .bat and .cmd. Let’s explore the differences between them.

About Batch Files

Files with both extensions .bat and .cmd can contain commands that run on Command Prompt.

When launched by double-clicking, Command Prompt starts up and the written commands are executed all at once.

In many cases, a window like the one below appears briefly and closes immediately. This indicates that the batch file execution has completed.

×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2025 Ribbit App Development All rights reserved.
 
C:\users\user>

Unless you intentionally include commands that wait for user input, this behavior is typical.

Differences Between .bat and .cmd

The differences between .bat and .cmd include the following points:

  • .bat is the extension used in versions before Windows NT. .cmd is the extension used in Windows NT and later versions.
  • .bat can be used in Windows NT and later versions, but .cmd cannot be used in versions before Windows NT.
  • .cmd is recommended for use in Windows NT and later versions.
  • .cmd allows for more flexible scripting than .bat.

In summary, .bat is the old format, and .cmd is the new format.

While what they can do differs, there is no major difference. Although .cmd is said to allow for more flexible scripting, almost everything that can be implemented in a batch file can be implemented with .bat as well.

Perhaps because of this, .bat is more commonly used for batch files in general.

Practice Quiz

Files containing commands that run on Command Prompt can have two types of extensions: .bat and .cmd. About the differences between them, select the statement that is incorrect from the following options.

#Command Prompt #Batch File #Arguments #Command Line #Command