1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.CMD .vs. .BAT

Discussion in 'Support' started by CSGalloway@nc.rr.com, Oct 21, 2010.

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

    rconn Administrator
    Staff Member

    May 14, 2008
    Likes Received:
    .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.)
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    May 20, 2008
    Likes Received:
    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.)
  4. samintz

    samintz Scott Mintz

    May 20, 2008
    Likes Received:
    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.


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


Share This Page