DOS - Powerful Enablers

Basic yet powerful features make DOS a quite interesting script language.

Description: One might say DOS is obsolete, other`s might just wonder why it`s still supported out-of-the-box in all Windows Operating Systems. This list of basic features may help understand.


DOS Batch Coding Guidelines - Readability, consistency and maintainability

Description: This section is yet to be written.


Reflection - A batch file can parse it`s own source script

Description: An executing DOS batch script is aware about the name and location of its own source file via the %0 batch parameter. This allows a batch to parse its own source file and change the execution path based on the parsing result. This is useful for e.g:
  • Storing configuration data or meta within the DOS batch and extract them file at runtime.
  • Storing data blocks within the DOS batch file and extract them at runtime.


Self Modification - A batch file can modify itself

Description: A batch file that is executing can modify itself with immediate effect. As it executes it can build the next command to be executed and append the new command to itself. This is useful for e.g:
  • Creation and execution of DOS code on the fly where as the created code becomes permanent part of the batch file itself.
  • Allows writing adaptive DOS Batch files


Variable Substitution - A variable substitutes a piece of command line

Description: In DOS a variable is simply a place holder for a piece of command line. At runtime a variable is simply being substituted by its string content. That’s why the string content can be a value, a command, partial value, a partial command or a mix of them. In case of substituting a variable to a command, this command to be substituted can use variables itself. This opens up a lot of space for creativity, e.g.:
  • Handling DOS code as data until execution
  • Creation and execution of temporary DOS code on the fly
See also string manipulation.