Windows batch files: .bat vs .cmd?
Windows batch files: .bat vs .cmd?
Windows batch files: .bat vs .cmd?
Re: Windows batch files: .bat vs .cmd?
From [this news group posting](https://groups.google.com/group/microsoft.public.win2000.cmdprompt.admin/msg/ad9066638815812c) by [Mark Zbikowski](http://en.wikipedia.org/wiki/Mark_Zbikowski) himself:
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.
In other words, if ERRORLEVEL is set to non-0 and then you run one of those commands, the resulting ERRORLEVEL will be:
- left alone at its non-0 value in a .bat file
- reset to 0 in a .cmd file.
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.
In other words, if ERRORLEVEL is set to non-0 and then you run one of those commands, the resulting ERRORLEVEL will be:
- left alone at its non-0 value in a .bat file
- reset to 0 in a .cmd file.