Windows batch files: .bat vs .cmd?

前端 未结 13 1736
傲寒
傲寒 2020-11-22 17:01

As I understand it, .bat is the old 16-bit naming convention, and .cmd is for 32-bit Windows, i.e., starting with NT. But I continue to see .bat fi

13条回答
  •  粉色の甜心
    2020-11-22 17:23

    From this news group posting by 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.

提交回复
热议问题