For years, PC users were forced to rely on Microsoft's clumsy command processor for scripting needs.
Very loosely based on the UNIX shell, but missing all the important features (regular expressions, looping constructs etc) , it was just about unusable.
However creative users began finding nifty little tricks and undocumented features which allowed batch files to do almost anything.

For many years, PC Magazine had a number of tips for batch programmers.
Some common tricks were:
  • Piping the output of any command or the contents of a file into the 'date' command, which would then generate output like "Enter new date:x y z". Redirecting this output into a batch file and running it would result in a batch file called enter.bat to be executed finally delivering the input as command line arguments to be parsed.
  • Storing goto label names in an environment variable to allow return to the same position simulating subroutine invocation.
  • Getting user input by using the FC (file compare) command with the console and the null device, and using the above date trick to parse its output.

Since Windows 2000, the command processor has been enhanced with:
  • The ability to execute multiple commands on a single line ( using &, &&, or || ) similar to UNIX shells.
  • Expression evaluation by the 'set' command.( Yes! you can do arithmetic ).
  • New operator %~ which retrieves file size, date, time and a host of other functions for a given file.
  • Enhanced 'for' command which can emulate a C for statement, recursively enumerate files, iterate over records in a file, iterate over command ouput a la the bash $() construct.
  • 'if' commands can now do lexicographic comparision of strings.
  • New predefined environment variables %RANDOM%, %TIME%, %DATE%.
  • The :EOF extension for 'goto' which allows subroutine like behaviour.
  • Extension to 'prompt' for showing UNC paths of network drives.
  • Selective 'shift' command.

All these features put together make the batch language powerful enough to write standalone applications. There were powerful programs written even in the old batch language (TIC-TAC-TOE for example) but not everyone could have written them. But it seems like too little, too late. Now theres VBscript and WSH and cygwin-bash and what have you. The one place where you really are stuck in the command line and need all the features is the Recovery Console and Microsoft's programmers have sadistically provided a shell that is even worse than DOS 2.0 ( NO wildcards!, NO history!, NO command completion!).

Is it Evil genius?
More like Pure Evil (tm)!!

DOS is not dead!!

Log in or register to write something here or to contact authors.