.cmd vs. .bat

J

John Goche

Hello,

Is there a difference between .cmd files and .bat files?
More precisely, is there an established convention as
to when to name a file containing a set of commands
with the .cmd extension as opposed to with the .bat
extension?

Thanks,

JG
 
P

Pop`

John said:
Hello,

Is there a difference between .cmd files and .bat files?
More precisely, is there an established convention as
to when to name a file containing a set of commands
with the .cmd extension as opposed to with the .bat
extension?

Thanks,

JG

No, there is no difference. .CMD is normally used in XP and beyond, plus
they kept the .BAT compatability for older scripts. They're all considered
script files.

The only difference is in the sequence in which files are searched for
execution. If you have say a 1.cmd and a 1.bat file inthe same folder and
it's in the path and you execute them by just typing "1", the cmd fill will
run. If no cmd files are found, then the bat file will run. Etc.

HTH
Pop`
 
K

Ken Blake, MVP

Pop` said:
The only difference is in the sequence in which files are searched for
execution. If you have say a 1.cmd and a 1.bat file inthe same
folder and it's in the path and you execute them by just typing "1",
the cmd fill will run.


It's the other way around. The 1.bat file will run.
 
B

Bob I

..cmd files are batch files that are intended to run on NT based Windows
while .bat files will run in the "DOS based" Windows AND/OR "NT based"
Windows. So ".bat" files should not reference any NT only programs or
command.
 
P

Pop`

Bob said:
.cmd files are batch files that are intended to run on NT based
Windows while .bat files will run in the "DOS based" Windows AND/OR
"NT based" Windows. So ".bat" files should not reference any NT only
programs or command.

That's incorrect; I just created a batch file that handles local gpo and and
another with some of the more mundane XP command prompt additions. It just
doesn't care. All they are is a script; what executes in one will execute
in the other.
 
B

Bob I

The operative words are INTENDED and SHOULD.
1. Go try running a .cmd file in Windows 95, 98, or ME
2. Try running a .bat file containing NT specific commands in Windows
95, 98, or ME.

Since you didn't try doing what the convention is intended to avoid, you
don't observe the problem of disregarding the convention. So, YOU would
be the one that is incorrect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top