Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I installed PGF but are unable to compile the following document:

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) --(1,2);
\end{tikzpicture}
\end{document}

This is the console output:

initexmf.exe: Windows API error 5: Access is denied.

initexmf.exe: Data: C:\
texify.exe: The operation failed for some reason.
texify.exe: Data: C:\Program Files\MiKTeX 2.9\miktex\bin\initexmf.exe

What to do?

share|improve this question
    
Welcome to TeX.sx! I improved the title a little to make it more descriptive. This will help people with the same issue to find it. I hope you don't mind. –  Martin Scharrer Apr 13 '12 at 17:38
1  
This seems to be an issue with your MikTeX installation rather with PGF/TikZ. Make sure that the output PDF is not already open, e.g. from an earlier compilation run. The Access is denied might be caused by that. Did you tried to reboot and try it again? Under Windows this is always good advice. –  Martin Scharrer Apr 13 '12 at 17:41
2  
After looking at docs.miktex.org/manual/initexmf.html, I think this might be because of Windows restrictions. Try to run MikTeX package manager and update the DB, at best using admin rights. Alternative try the initexmf --admin --update-fndb in the console as mentioned in the link. –  Martin Scharrer Apr 13 '12 at 17:43

8 Answers 8

You have to give yourself the permissions to read and write in MiKTeX 2.9 folder.

Go to Program Files and right click MiKTeX 2.9 folder. Then click Properties > Security Tab > Edit Button. Select Users (Bla/Bla) from the list and check all grants.

If that is not enough, click Advanced button on the Security Tab. A window named Advanced Security Settings for Folder Name pops up. Then click Auditing Tab > Continue Button > Add Button. Type Users under "Enter the object names to select" and click OK.

Or, simply don't put your MiKTeX 2.9 folder into Program Files.

share|improve this answer
1  
This solved my problem with installing or updating packages that I had after a fresh install of MiKTeX 2.9 64 bit to Program Files. Thanks! –  doncherry Dec 22 '12 at 0:28

This seems to be some form of conflict between MiKTeX and another software, maybe Adobe Reader.

I looked around and found the following related post with a solution. It is about the installation, not compilation but the reason and fix should be identical:
http://entangled.wordpress.com/2009/09/18/installation-of-miktex-2-8-failed/

A possible solution was posted as a comment there:

I have got the real solution :)
Run regedt32.exe, then navigate to HKEY_CLASSES_ROOT\.pdf
Rightclick .pdf, click permissions, and grant the administrator full rights.

share|improve this answer

I found another potential solution to this problem: make sure that your TMP environment variable points to a writable source. For instance, I changed my TEMP and TMP environment variables (System -> Advanced -> Env. Variables) to a drive other than C:, but I accidentally had the TMP instance point to the D: drive instead of E: -- the former was unwritable. The API Access Error 5 for the MikTeX installation/removal was resolved when I fixed the TMP path.

Hope that helps someone.

share|improve this answer

Apparently you need Administrator rights. What is important is how you installed miktex. If you are asked wether you want to install miktex just for the current user or for all, I reccommend selecting install for all. If you select just for me, it is installed without admin rights, even if the logged in user is in fact an Administrator.

In short: uninstall and install with option "install" for all users" fixed it for me

share|improve this answer
    
I in opposition recommend for the single user installation, if you’re the only (TeX) user on your system, cf. Difference between administrative and user mode of MiKTeX. –  Speravir Dec 26 '12 at 3:20
    
The default installation directory is program files, which causes trouble when installing in user mode. When one is experienced enough to change it to the %appdata% folder, that could work. Haven't tried it. –  Nino Dec 26 '12 at 17:13
    
1.) The user must have access to his/her own user profile (where %appdata% is in). Otherwise the whole Windows installation would be defunct, so the issue with MiKTeX considered harmless. 2.) The single user installation should be best done outside of C:\Program Files, e.g. put everything LaTeX related into C:\LaTeX. 3.) You should add a link to Relocate MiKTeX 2.9? in your answer. –  Speravir Dec 26 '12 at 21:01

I found this error as I was trying to install MiKTeX from the downloaded folder. I copied the file to a new folder and it worked properly.

share|improve this answer
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format –  texenthusiast Aug 6 '13 at 17:22

The problem is that in Windows-MiKTeX the following code:

(attributes & FILE_ATTRIBUTE_READONLY) != 0

(search for it in *.cpp files) does not function correctly (e.g. install MikTeX to the program folder and then try to run it without admin rights). After replacing the above code with:

true

the compiled MiKTeK does run without admin rights. Of course, there should be a better solution, replacing the code with something that supplies the correct answer to the read-only question.

share|improve this answer

In my case, I closed Kile, simply deleted every file, except the BIB and the TEX files, and re-ran PDFLaTeX. That solved it.

share|improve this answer

Right click and "Run as an administrator" will resolve the issue.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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