Batch files are executed in an interpreted manner by the shell (in Windows, this is cmd.exe
). The shell reads each line of the file starting from the top, and executes the line as a command as if you had typed it in to the command prompt.
There are exceptions such as the goto
command, which doesn't make sense if you type it at the command prompt, but does when executed in a batch file. When seeing the goto
command, the shell will go back to the start of the file and read each line in turn until it finds the label indicated in the goto
. Then it starts executing from there.
The above method is interpreted and not compiled, so it is much less efficient at execution than a compiled language like C++. I would never call batch files "extremely efficient". Maybe "extremely inefficient".