Re: What is the difference between CMD and BAT file ?



Forgot this.

..CMD will be listed in PATHEXT under Set in NT in a command prompt and will
NOT be listed under non NT i.e. Windows 9x, Me, etc.

The environmental variable PATHEXT shows a list of file extensions that are
considered to be executable and regulates which extensions do not need to be
typed in a Command Prompt or the Run command.

---------------------------
Report Class Name
---------------------------
File Extension .cmd
File Class cmdfile
File Description Windows NT Command Script

Files of .cmd will be listed in the File Types dialog box as Windows NT
Command Script.
---------------------------

Report Class Name
---------------------------
File Extension .bat
File Class batfile
File Description MS-DOS Batch File

Files of .bat will be listed in the File Types dialog box as MS-DOS Batch
File.
---------------------------

There is a difference in NT on how .cmd and .bat files are handled.

<quote>
The differences between .CMD and .BAT as far as CMD.EXE is concerned are:

With extensions enabled, PATH/APPEND/PROMPT/SET/ASSOC in .CMD
files will set ERRORLEVEL regardless of error. .BAT sets ERRORLEVEL
only on errors.

Mark Zbikowski \(MSFT\)
<quote>
from...
http://groups.google.com/group/microsoft.public.win2000.cmdprompt.admin/msg/ad9066638815812c


--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:uVLuH0mwGHA.4160@xxxxxxxxxxxxxxxxxxxx,
Wesley Vogel <123WVogel955@xxxxxxxxxxx> hunted and pecked:
.cmd files will NOT work on non NT Windows versions where .bat files will.

Both .cmd and .bat files work on NT Windows versions.

Windows XP is really Windows NT 5.1.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:OR8iYlmwGHA.4160@xxxxxxxxxxxxxxxxxxxx,
John <John@xxxxxxxxxxxxxxxxxxxxxxxxx> hunted and pecked:
Hi,

Could anyone give me some advice on when to use CMD and BAT file ?

This is because we are going to run some scripts to delete the shortcuts
in desktop. We already got the command but some fellow says it should
be with BAT extension and some with CMD one.

Your advice is sought.

John

.



Relevant Pages

  • Re: How To Execute Batch File Line By Line
    ... COMMAND /C string Carries out the command specified by string, ... CMD /C Carries out the command specified by string and then terminates. ... .cmd files will NOT work on non Windows NT versions i.e. Windows 9x, ... Both .cmd and .bat files work on Windows NT versions. ...
    (microsoft.public.windowsxp.general)
  • Re: How To Execute Batch File Line By Line
    ... COMMAND /C string Carries out the command specified by string, ... CMD /C Carries out the command specified by string and then terminates. ... Both .cmd and .bat files work on Windows NT versions. ... File Description MS-DOS Batch File ...
    (microsoft.public.windowsxp.general)
  • Re: What is the difference between CMD and BAT file ?
    ... I have two .cmd files that are part of XP. ... my understanding is that BAT can be applied to both NT ... NOT be listed under non NT i.e. Windows 9x, Me, etc. ... typed in a Command Prompt or the Run command. ...
    (microsoft.public.windowsxp.general)
  • Re: Issue in execution of batch files Windows XP Pro
    ... Simply correcting the extension ... identically by Windows. ... I personally stick with CMD for NT operating systems, ... use BAT on the 98 boxes. ...
    (microsoft.public.windowsxp.general)
  • Re: Issue in execution of batch files Windows XP Pro
    ... Simply correcting the extension will cause desired behaviour. ... Both .cmd and .bat are "correct" extensions for a batch file and they are treated almost identically by Windows. ...
    (microsoft.public.windowsxp.general)