My xelatex application in "C" directory.

My Tex file is in "D" Directory.

How can I run my tex file in "D" Drive?

and cmd prompt?

  • At least provide some detail on the operating system that you're using, as well as the location (folder) of your xelatex installation. My answer below is based on a suggestion that you're running Windows.
    – Werner
    Commented Jul 28, 2011 at 6:32
  • The TeX Live installer should have added xelatex (and other tex-related executables) to your path, so that they should be accessible by just typing their name. Did you try that? For example tex --version should workd regardless of your current directory. If this is not the case, please provide more information about the way you installed TeX Live. If the installation went badly, it's probably better to reinstall than to try fixing the PATH manually, since probably other things are borken too.
    – mpg
    Commented Jul 28, 2011 at 10:59
  • By the way, the latex-project tag seems hardly relevant to me.
    – mpg
    Commented Jul 28, 2011 at 11:02
  • 1
    Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close. Commented Jul 11, 2015 at 17:59

2 Answers 2


You need to append "the path to your TeX distribution" to PATH environment variable. To do so, follow the following steps:

  1. Open Windows Explorer (not Internet Explorer), and search for Control Panel\All Control Panel Items\System. The shortcut is Win+Break (pressing and holding the Windows Flag button followed by pressing Break button).

    enter image description here

  2. Click Advanced system settings.

    enter image description here

  3. Click Environment Variables...

    enter image description here

  4. You will see 2 sections, one for User Variables and the other one for System Variables. For the sake of convenience, concentrate on the System variables section, locate Path and double click.

    enter image description here

  5. Depending on your TeX distribution path, append ; followed by your TeX distribution path to the end of Variable value:. For example, if your TeX distribution path is C:\Program Files\texlive\2011\bin\, then append ;C:\Program Files\texlive\2011\bin\ to the end of Variable value: as the following figure.

    enter image description here

  6. Confirm the changes by clicking OK buttons. Done! Now you can invoke xelatex from any directory as follows.

    enter image description here


Assuming you are running Windows (since you mention 'cmd prompt'), you should be able to execute

C:\>xelatex D:\myfile.tex

If Windows outputs

'xelatex' is not recognized as an internal or external command,
operable program or batch file.

then you have two options. Either set your Windows path environment variable. The way this is done varies depending on your system, so see some guidelines depending on whether you are running Windows 2000, XP, Vista or 7. Alternatively, you can expand the entire directory where your xelatex installation is located, for example:

"C:\Program Files\texlive\2011\bin\xelatex" D:\myfile.tex

Note that you need to use quotes "" if your directory structures contain spaces. If your LaTeX file is not in the D:\ root directory/folder, then you'll have to include the entire path, as above, making sure you use quotes if the path contains spaces:

C:\>xelatex "D:\Documents and Settings\User\myfile.tex"

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