4 ms·
Every time I see 'DOS' tutorials like this, I realise that I'm in a minority that uses .cmd as [Windows]DOS batch file extensions and not .bat The reason for t
by Jaruzel 5y ago
Every time I see 'DOS' tutorials like this, I realise that I'm in a minority that uses .cmd as [Windows]DOS batch file extensions and not .bat
The reason for this (for those that don't know) is that when 32-bit Windows arrived, the DOS 32-bit shell (cmd.exe) was introduced alongside the traditional command.com and with it added a bunch of new shell commands and options. To call cmd.exe instead of command.com you would use .cmd as your batch file extension instead of .bat.
This was done to ensure ongoing 100% compatibility of legacy .bat files with command.com
Even after Microsoft killed off command.com and remapped .bat to cmd.exe I still used .cmd as the file extension and still do to this day.
Seeing people use .bat makes me realise that a lot of people never went through this transition and are probably unaware of the .cmd extension.
- LeonB 5y agoAuthor here. In dos on dope, .bat files are used for actions that handle http GET, and .cmd files are used for actions that handle http POST. Btw I did live through that transition. (?)
- quietbritishjim 5y agoOdd, I lived through the same period, and don't recall a situation where .cmd vs .bat ever made a difference to the interpreter. On DOS-based Windows (i.e. up to 3.1, and then 95/98/ME) only COMMAND.COM was available, so certainly that was always used as the interpreter. The native Windows 32-bit cmd.exe was introduced on NT-based Windows (i.e. 3.1/3.5(1)/4/2000, then XP and all following mainstream Windows). A virtualised form of DOS was available on the NT line so in principle you could also run your batch files through the old COMMAND.COM. This is where I'm least confident, but I thought that the extension wouldn't make that choice though - it would use the 32-bit cmd.exe even if the extension was .bat, unless you explicitly started a DOS instance and ran it through that. After all, one of the design goals of cmd.exe was to be a drop-in replacement for the old DOS interpreter.
- GordonS 5y agoHmm, same here, I've never known any difference. I do use `.cmd` instead of `.bat`, but only through personal preference, nothing more.
- Jaruzel 5y agoWikipedia link on the differences: https://en.wikipedia.org/wiki/Batch_file#Filename_extensions https://en.wikipedia.org/wiki/Batch_file#Filename_extensions Which also links to: http://waynes-world-it.blogspot.com/2008/08/difference-between-bat-and-cmd.html http://waynes-world-it.blogspot.com/2008/08/difference-betwe... There used to be a microsoft.com page on it too, but that's been lost to time.
- quietbritishjim 5y agoThose articles match my understanding, but it's a bit different to your previous comment (but maybe I misunderstood your previous comment). I thought you were saying that there was at least one version of Windows where .cmd would run in cmd.exe while .bat would run on COMMAND.COM. Whereas I think the actual situation is that: on Win95 .bat would run on COMMAND.COM whereas .cmd wouldn't run at all; on NT .bat and .cmd would both run on cmd.exe. As a result, if you used .cmd you could be sure that it would never run on COMMAND.COM, so you could use the new command extensions in cmd.exe without worrying about it causing a confusing error.
- Jaruzel 5y agoNow you say it, I'm not sure either tbh. During that period I was principally an NT user, and I never really used 95/98. When I get a mo, I might fire up an NT VM and see what actually happens. Maybe.... .bat and .cmd DO both run cmd.exe, but the former disables the command extensions?
- unixhero 5y agoThere is also .ba1 which I have no idea what is.
- porbelm 5y agoYeah, I remember this, having used DOS since 5, but never used advanced enough stuff to justify forcing cmd.exe