\write18: Running Programs From Within TeX

TeX handles output stream 18 in a special way: the token list is interpreted as a command-line. If the \write18 feature is enabled (see below), then \write18{toklist} starts the command interpreter (usually cmd.com) to carry out the command specified by toklist. For example:

\write{dir}

lists the files and sub-directories of the current directory.

TeX ignores \write18 by default (for security reasons). You enable the feature by using the TeX compiler option -enable-write18.