Is there a way to execute a .bat file directly from a latex document when I compile that document?

I would something like this:


bla bla bla
  • Are you thinking to launching MakeIndex from inside your LaTeX run?
    – egreg
    Dec 3, 2012 at 17:10
  • 3
    You want \write18. For that to work, you will need to compile with --shell-escape.
    – G. Poore
    Dec 3, 2012 at 18:49
  • @egreg Thanks, but I know your package "imakeidx" : )
    – Aurelius
    Dec 4, 2012 at 17:13

1 Answer 1


You have to run LaTeX (latex, pdflatex, xelatex or lualatex) with the -shell-escape option: then this code defines what you need.

    \GenericError{}{Shell escape not enabled}{}
      {You have to run (pdf)LaTeX with the option `-shell-escape'}%

However, if your purpose is to run MakeIndex, then the imakeidx package does it without user intervention (not with the article class unless some precautions are taken).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.