28

I have tried my best, but don't seem to get this one right. How do I enable shell escape in MikTeX?

Why XeLaTeX comes with a default for shell escape but not LaTeX?

6
  • It might be useful to say what you've tried: for example, what suggests to you that there is a difference between latex and xelatex?
    – Joseph Wright
    Dec 7, 2011 at 19:13
  • 2
    Usually just use -shell-escape (or whatever MikTeX has for it as a command line option) Dec 7, 2011 at 19:15
  • 5
    @MartinScharrer Either --shell-escape or --enable-write18.
    – Joseph Wright
    Dec 7, 2011 at 19:18
  • @JosephWright with pdfLaTeX direct compilation of pst is possible with `\usepackage{auto-pst-pdf}. With pdfLaTeX I get the error "shell escape" (or "write18") is not enabled.
    – mathspasha
    Dec 7, 2011 at 20:41
  • 1
    Did you try to add the option in the preferences dialog, as described here. So you can add the option -shell-escape or -enable-write18 to a new command that you are defining. I remember reading somewhere that the -shell-escape option is not safe (maybe someone can elaborate on this), but I'm not sure and can't find that statement. So, maybe, putting it by default is not a good idea.
    – adn
    Dec 8, 2011 at 2:48

2 Answers 2

24

A similar question came up recently in a German user forum. The user found the answer in the end with help of this link

You can enable write18 by writing

initexmf --edit-config-file=miktex\config\pdflatex.ini

in DOS. You can get to the DOS window by hitting the windows Start button, click on "run" and write "cmd" (without the quotes obviously, this might also be slightly different for win7, I think there you can write cmd right in the search line that comes up after hitting the start button).

It might as well also work to do Start->run and then paste the above line right into this little run window (see below)

the pdflatex.ini should open in an editor and you can enter

EnableWrite18=t

save and close the file. Now it should be permanently enabled with pdflatex.

Another way is to pass -enable-write18 to pdflatex. This can usually be done in the editor of your choice. For example in TeXnicCenter it looks something like:

Path of the compiler:

C:\...\pdflatex.exe (this is set already)

Arguments passed to the compiler

-interaction=nonstopmode -enable-write18 %tm

enter image description here

Update:

To do this on WinEdt, do the following:

  1. Go to Options and click on Execution Modes (See image below)

    enter image description here

  2. Enter --enable-write18 under the pdflatex Accessories under switches as shown in the diagram below.

    execution modes interface

5
  • This hack also works when using pdf2latex under Linux.
    – Bryson S.
    Apr 29, 2015 at 2:53
  • With the pass-through option to pdflatex (with TeXStudio) I had to run the editor as Administrator under Windows 10 for this to work. Jul 18, 2016 at 5:54
  • Enabling this globally as default is terrible advice. There is a reason this is not the default. You should at least include a clear warning about the risks of doing this.
    – cfr
    Feb 19, 2017 at 3:22
  • I tried this with my winedt and miktex setup and still can't get a basic gnuplot to work... Might there be something else stopping miktex and gnuplot from interacting properly?
    – JohnD
    Nov 24, 2019 at 17:52
  • @JohnD maybe try running the editor as admin as a test
    – Martin H
    Nov 25, 2019 at 18:11
7

In Windows + TexWorks, when using texify, I have to add:

--tex-option=--shell-escape

To the tool configuration window:

TexWorks options for --shell-escape on Windows

Source: How to do shell-escape in TeXWorks?

1
  • As of 2021, you probably want the more secure --shell-restricted, and to add the executable you want to run to the configuration file.
    – Davislor
    Jun 16, 2021 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .