CMD vs BAT
CMD vs BAT
The importance of the batch file can be easily understood by the power users and system administrators. But, generally most of the regular computer users are unaware of these files. This indicates that people are not utilizing this powerful tool for their repetitive or routine work. Though these files are used for quite complicated and sophisticated system by network administrators but they can also be utilized with simplicity for more useful tasks.
Batch files are the text files that contain lines with commands and further can be executed in sequence. These files are saved with the special extension named as BAT and CMD.
BAT and CMD files are assigned to automate the tasks that are in repetitive manner or frequently used by the users. These files are used as simple programming language along with its pros like command line instructions.
Below table enumerates difference : CMD vs BAT
- Readability: BAT is the older format of file as this type of file was invented during the invention of DOS. It was taken by the Microsoft when the windows were away from the DOS. On the other hand, Microsoft invented the CMD file type to use the Windows NT command scripts.
- Interpreter: BAT was formed to interact with the command interpreter of DOS that is COMMAND.COM, whereas CMD was invented to interact with CMD.EXE that further breaks the compatibility with COMMAND.COM.
- Error Level: The next key difference is handling the error level of the variable.While using the BAT, once the actual error occurs the variable can change and does not affect the state when the command is executed. But with the case of CMD the variable will change its states even if there are no errors. Programmers should remember this while creating or elaborating the scripts as this can cause a little bit of confusion.
- Support: BAT files are not supported by the new version of windows while the CMD files are supported by almost all versions of windows.
- Language: BAT is the scripting language that has an interpreter and CMD is the programming language that helps to run the scripts and has the command interpreter.
- Security: When the BAT file is opened, it runs the command which is not good for security purpose while in CMD it does not run the command though quite safer than BAT.
- Run: To run a BAT script, just the filename is sufficient for the program whereas to run a CMD script, we have to enter the filename.cmd. This happens only when both BAT and CMD files have the similar filenames.
Beside those minor contrasts, CMD and BAT are indistinguishable from one another. For clients of the later version of Windows, BAT and CMD are basically compatible as CMD.EXE would interpret and execute the command in both types of files.
BAT files have their own way of execution and are not always executed using command prompt while the CMD often uses command prompt, though command prompt runs many programs as directed.