Using extension .BAT is the same as .CMD ?

June 15, 2010 at 07:03:53
Specs: Windows XP
Hello.
Using a batch-file with the extension .Bat is the same using extension .CMD ?

I created a batch-file under Windows XP and I gave it the extension ".BAT". This batch-file must be used only under Windows 2000/XP. It is incompatible with Windows 9x or below.
I read that to avoid a batch-file (created for WinNT*-only) be executed under Windows 9x I must rename it with the ".CMD" extension.

Now I was wondering, if I rename the file from "mybatch.BAT" to "mybatch.CMD" change anything?
It is just a way to distinguish the two files or something is changing? The command syntax is the same? Windows will execute the file in the same way?
Can I rename SAFELY any batch-file (created for Windows NT/2K/XP) from ".BAT" to ".CMD" extension?

thank you so much.
Turrican


See More: Using extension .BAT is the same as .CMD ?

Report •


#1
June 15, 2010 at 07:43:00
Turrican,

In almost all cases, batch files can be named with either .bat or .cmd extensions. As far as I know, there are only some minor differences in the values returned for the errorlevel variable.

Here's some additional information:

http://en.wikipedia.org/wiki/Batch_...

-- kptech


Report •

#2
June 15, 2010 at 09:05:53
thanks!

Report •

#3
June 15, 2010 at 11:45:57
Calling a BAT a CMD will, sooner or later, throw a wrench in the works.

If you want to prevent an NT BAT from running in DOS, try this:

=======================================================

@echo off > quit.bat
if not %OS%==Windows_NT echo for NT only & quit


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
June 17, 2010 at 11:05:59
Well, I used your solution on several occasions.
In this case I can not use it because with that way I could not create a batch-file for Win98 users.

Instead I decided to create:
INSTALL.CMD - for Win NT/2K/XP/Vista/7 users. and
INSTALL.BAT - for DOS/Windows9x users.

That way I can satisfy both.
As you know, in this way Win9x users can NOT execute the batch-file for WinNT users!


Report •

#5
June 17, 2010 at 13:06:34
if not %OS%'==Windows_NT' goto :notNT


=====================================
Helping others achieve escape felicity

M2


Report •

Ask Question