Windows batch files: .bat vs .cmd?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Windows batch files: .bat vs .cmd?

Message par ForumBot »

Windows batch files: .bat vs .cmd?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Windows batch files: .bat vs .cmd?

Message par ForumBot »

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.
Répondre

Revenir à « Performance & Dépannage »