Alex Rivera | Logout

Windows batch files: .bat vs .cmd?

Asked 2008-09-29T14:39:07.190
921

As I understand it:

  • .bat is the old 16-bit naming convention
  • .cmd is for 32-bit Windows, i.e., starting with NT.

But I continue to see .bat files everywhere, and they seem to work exactly the same using either suffix.

Assuming that my code will never need to run on anything older than NT,
does it really matter which way I name my batch files,
or is there some gotcha awaiting me by using the wrong suffix?

Edit
Report

2 Answers

-2

The extension makes no difference.

There are slight differences between COMMAND.COM handling the file vs CMD.EXE.

answered 2008-09-29T14:45:17.330
-10

a difference:

.cmd files are loaded into memory before being executed. .bat files execute a line, read the next line, execute that line...

you can come across this when you execute a script file and then edit it before it's done executing. bat files will be messed up by this, but cmd files won't.

answered 2010-04-03T20:22:22.120

Your Answer