.CMD .vs. .BAT

  • Thread starter CSGalloway@nc.rr.com
  • Start date
C

CSGalloway@nc.rr.com

Guest
I have RTFM but don't really understand the difference between the two file extensions. Would someone please explain.....???
 

rconn

Administrator
Staff member
May 14, 2008
12,348
150
I have RTFM but don't really understand the difference between the two file extensions. Would someone please explain.....???

.BAT is an obsolete extension originally used by 16-bit versions of COMMAND.COM in DOS and Windows 95/98.

.CMD is the batch file extension for files executed by the 32-bit CMD.EXE in Windows.

If you're running Vista or Windows 7, there's no difference at all between the behavior of .BAT and .CMD files; TCC (or CMD) execute them identically.

If you're running Windows XP or earlier, a .BAT file is actually executed by the stub version of COMMAND.COM, which passes most (but not all) of the commands on to CMD.EXE. (The point of this is to allow you to run old DOS batch files that contain TSRs, which are not supported in newer versions of Windows.)
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,463
88
Albuquerque, NM
prospero.unm.edu
I have RTFM but don't really understand the difference between the two file extensions. Would someone please explain.....???

TCC handles .BAT and .CMD files the same way: one line at a time is read from the file, and the file is closed before the line is executed. That's a file open, seek, read and close for each line, which can slow a batch file down significantly, e.g. over a network connection.

.BTM files are handled differently. The entire file is slurped into memory once, saving a whole lot of file-system overhead. .BTM files can be noticeably faster. (The downside is that they can't self-modify on the fly -- a nasty technique best avoided anyway.)
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
For all intents and purposes they are the same. I seem to recall Rex
saying something about COMMAND.COM sends .BAT statements to CMD.EXE to
execute. And CMD files are executed directly by CMD.EXE.

Historically, .CMD files came from OS/2. When OS/NT turned into WinNT, it
just naturally supported them I suppose.

I know that execution of a .BAT file is line by line. I.e. the file is
opened, the next line is read, the file is closed. And so on. That
allows .BAT files to be self-modifying.
BTM files are read as a whole. I don't know if there are any special
execution idioms around CMD files.

-Scott

Kachupp <> wrote on 10/21/2010 09:56:44 PM:


> CMD and BAT files are the same .. CMD files are executed by CMD.EXE,
> BAT files are executed by command.com
>
>
>
> ---Quote---
> > -----Original Message-----
> > From: CSGalloway@nc.rr.com [mailto:]
> > Sent: Friday, 22 October 2010 1:31 p.m.
> > To: kachupp@gmail.com
> > Subject: [Support-t-2357] .CMD .vs. .BAT
> >
> >
> > I have RTFM but don't really understand the difference between the
> two file extensions. Would
> > someone please explain.....???
> >
> >
> >
> >
> >
> >
> ---End Quote---
>
>
>
 
Similar threads
Thread starter Title Forum Replies Date
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
E How to? use Executable Extensions: .bat and .cmd Support 8
C Documentation .CMD .BAT .BTM Support 15
C .bat files works in cmd.exe, not in TCMD Support 6
CWBillow TCC and CMD / BAT files Support 3
T WAD CMD incompatibility Support 14
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
L FTYPE in TCC, less quirky than in cmd.exe Support 3
Peter Murschall Single-line Do-CMD is a bit uncooperative. Support 6
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
T Date format date different from cmd Support 7
D Differences between TCC and CMD with COPY /b Support 4
E TCC/CMD difference Support 5
D How to? Pass OpenHere Folder to CMD? Support 6
R Difference between TCC and CMD: variable names with hyphens Support 4
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
rps Cmd history recall Support 4
rps Documentation TITLE cmd docs Support 0
Joe Caverly PUSHD with UNC path in CMD.EXE Support 2
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
Joe Caverly Using this CMD technique from TCC Support 17
W If command - different with CMD Support 6
I how to make TCC default/replace cmd.exe? Support 9
R FOR usage error from TCC but not from CMD Support 16
I findstr works in cmd but not in tcc Support 5
D Pasting Unicode data has different behavior on TCC and CMD Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
Joe Caverly tcommand(cmd) Support 13
L WAD ECHO. expansion of non-existent env-vars differs from CMD.exe Support 6
Joe Caverly "Functions" in cmd.exe batch files Support 6
Joe Caverly Works in debugger, not from cmd line Support 1
K CMD, TCC, VisualStudio 2017, VcVars* differences Support 1
D Does TCC improve CMD's implementation of ECHO? Support 6
P Labels in batch files: TCC vs CMD.exe Support 9
Patulus Yet another thread on CMD compatibility Support 16
A Fixed (CMD compat) START /D fails to recognize the switch option. Support 3
Joe Caverly CMD.EXE and filename(1).ext Support 3
H DOS CMD Sort+Add Sequence+Remove Sequence number Support 12
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
C Nested IF syntax — TCC behaving differently to CMD Support 12
T CMD incompatibility Support 14
V Network share slowness vs CMD? Support 19
P Fixed Rexx .cmd files no longer work in TCC 20 Support 3
TT's Help! Uninstalling TCC did not restore cmd.exe as Win10 default batch file processor. Support 4
R How to? Display text same as in CMD Support 14
D Tab completion differences with cmd.exe Support 3
deleyd Fixed Behavior different than CMD Support 1
vefatica START, CMD vs. TCC Support 0

Similar threads