For years, PC users were forc
ed to rely on Microsoft
's clumsy command processor for script
Very loosely based on the UNIX
shell, but miss
ing all the import
ant features (regular expression
ructs etc) , it was just about unusa
ive users began finding nifty little tricks and undo
cumented features which allow
ed batch files to do almost anything.
For many years, PC Magazine
had a numb
er of tips for batch program
- 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.
dows 2000, the command process
or 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 power
ful enough to write standalone
ions. There were powerful programs written even in the old batch language (TIC-TAC-TOE for exam
ple) but not every
one could have written them. But it seems like too little, too late. Now theres VBscrip
t 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 Recover
y Console and Microsoft's program
mers have sadist
ically provided a shell
that is eve
n worse than DOS 2.0 ( NO wild
cards!, NO history
!, NO comma
Is it Evil genius
More like Pure Evil
DOS is not dead!!