I would like to know whether a simple batch file that runs perfectly in modern Windows will run the same in FreeDOS/MS-DOS. Are most of the normal commands like if, echo, set, cd, md, etc. the same?
Asked
Active
Viewed 207 times
0
-
1Of the commands you listed only `echo` is exactly the same. The others all support various extensions that MS-DOS didn't. You can write a simple batch script that will work the same on both Windows and MS-DOS, but most batch scripts written for Windows will use one extension or another, even many simple ones. – Ross Ridge May 31 '16 at 06:27
-
1@RossRidge is right, you can expect very limited backward compatibility only, read [Microsoft DOS cmd and command](http://www.computerhope.com/cmd.htm) for details. – JosefZ May 31 '16 at 06:35
-
This question is more suitable on [SuperUser](http://www.superuser.com/) in my opinion. Anyway, For a Windows (NT) script to be backward-compatible with MS-DOS, you need to disable the command extensions (type `cmd /?` and see `/E`, see `setlocal /?` for batch files); unfortunately this does definitely not guarantee the compatibility, but comes way closer; `cmd /?` provides (sadly an incomplete!) list of commands affected by the command extensions; when typing such a command and `/?`, the related help text usually contains a section `If Command Extensions are enabled <...> changes as follows:` – aschipfl May 31 '16 at 08:23
-
Dos batch files run on windows without any changes. Windows adds extra features, if you don't use them then it will run on both. If on 32 bit windows you can use command.com to run you batch as Dos 5.5. On 32 bit windows DOS help is available on a command by typing `command /c dir /?`. You must type it exactly as shown. Command.com on 32 bit windows passes all commands typed (but not passed as parameters) to CMD.EXE. – May 31 '16 at 12:02
-
1There are a few points that works different on MS-DOS command.com vs. Windows cmd.exe. For example, `REM > EMPTY.TXT` create an empty file and `DIR NAME` imply `DIR NAME.*`. If these or other similar "features" would be used in an old Batch file, it would not work in cmd.exe. – Aacini May 31 '16 at 13:59
-
See also [Windows batch files: .bat vs .cmd?](http://stackoverflow.com/questions/148968) which partially answers this question. It has also been addressed in more details in the Retrocomputing stack exchange: [How do modern .bat files differ from old MS DOS .bat files?](https://retrocomputing.stackexchange.com/questions/1891) – Cebe May 16 '17 at 10:16