Windows批处理文件:.BAT VS .CMD? [英] Windows batch files: .bat vs .cmd?

查看:191
本文介绍了Windows批处理文件:.BAT VS .CMD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,的.bat 是旧的16位命名约定,和的.cmd 是32位Windows,即开始NT。但我仍然看到.bat文件随处可见,他们似乎使用或者后缀的工作完全相同。假设我的code将永远需要比NT任何旧的运行,是否真的重要走哪条路我名字我的批处理文件,还是有一些的疑难杂症使用错误的后缀等着我?

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 files everywhere, and they seem to work exactly the same using either suffix. Assuming that my code will never need to run on anything older than NT, does it really matter which way I name my batch files, or is there some gotcha awaiting me by using the wrong suffix?

推荐答案

维基百科

维基百科的新报价

的.cmd之间的唯一区别知
  和.bat文件执行是在
  .cmd文件的ERRORLEVEL变量
  甚至改变一个成功的命令
  即受命令扩展
  (当命令扩展被启用)
  而在.bat文件的ERRORLEVEL
  只有在错误变量的变化。

The only known difference between .cmd and .bat file execution is that in a .cmd file the ERRORLEVEL variable changes even on a successful command that is affected by Command Extensions (when Command Extensions are enabled), whereas in .bat files the ERRORLEVEL variable changes only upon errors.

以上维基百科注明出处实际上是基于<一个href=\"https://groups.google.com/group/microsoft.public.win2000.cmdprompt.admin/msg/ad9066638815812c\">this新闻组发布。

The source for the Wikipedia quote above is actually based on this news group posting.

据CMD.EXE .CMD和.BAT之间的差异关注
  分别是:启用扩展,PATH /添加/ PROMPT / SET /在.CMD ASSOC
  文件将设置ERRORLEVEL不分的错误。 .BAT设置ERRORLEVEL
  只上的错误。

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.

它不仅是一点点更严格的有关分歧,不是维基百科的文本,但也值得被明确提及,给了它被张贴的马克·茨柏克沃斯基的自己 - 这给了巨大的信誉奖金恕我直言

Not only is it a little more restrictive concerning the differences, than the Wikipedia text, but is also worth being explicitly mentioned, given the fact it was posted by Mark Zbikowski himself - which gives a huge credibility bonus IMHO.

这篇关于Windows批处理文件:.BAT VS .CMD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆