[Tex/LaTex] When trying to install MiKTeX: Windows API error 5: Access is denied

miktexmiktex2.9

I tried to download the current version (2.9(.7086)) of MiKTeX for Windows (64 bit). When I try to install it (no matter if only for one user or all, I tried both) it shows me the following error message:

Windows API error 5: Access is denied.
info: path="Software\MiKTeX.org\MiKTeX\2.9\Core"

The last part of the log looks as follows:

56 [0x00003d78] INFO initexmf null - starting: MiKTeX Configuration Utility 2.9.7076 (MiKTeX 2.9.7050 64-bit)
56 [0x00003d78] INFO initexmf null - Operating on the private (per-user) MiKTeX setup
56 [0x00003d78] INFO initexmf null - starting with command line: initexmf "--user-install=C:\Users\anapa\AppData\Local\Programs\MiKTeX 2.9" "--common-install=C:\Program Files\MiKTeX 2.9" --set-config-value=[Core]SharedSetup=0 "--log-file=C:\Users\anapa\AppData\Local\Programs\MiKTeX 2.9\miktex/config\uninst.log" --disable-installer --verbose
63 [0x00003d78] INFO initexmf null - Registering root directories...
Registering root directories...
71 [0x00003d78] FATAL initexmf null - Windows API error 5: Access is denied.

71 [0x00003d78] FATAL initexmf null - Info: path="Software\MiKTeX.org\MiKTeX\2.9\Core"
71 [0x00003d78] FATAL initexmf null - Source: Libraries\MiKTeX\Core\win\winRegistry.cpp
71 [0x00003d78] FATAL initexmf null - Line: 173

Sorry, but "MiKTeX Configuration Utility" did not succeed.

An error occurred:
  source file: Libraries\MiKTeX\Core\win\winRegistry.cpp
  source line: 173
  message: Windows API error 5: Access is denied.
  info: path="Software\MiKTeX.org\MiKTeX\2.9\Core"
s
<<< Cancel? Yes! >>>

I one had MiKTeX installed on my Laptop, unfortunately had to deinstall it after I stopped using it for a while. I did scan my Laptop for the word TeX aswell as MiK, as to delete all files from the previous installation.

I am the admin of this Laptop.

Does anyone know what the problem might be?

Best Answer

NOTE a number of users have reported problems installing when the file name is changed, as far as I know there is only ONE filename change recommended by MiKTeX (see end comment about portable), otherwise assume the filename must not be changed during or after download so the installer can compare its own functionality.

API error 5: can happen with a download that is a few bytes short of a full load I can get either of these messages from exactly the same bad file

enter image description here enter image description here

First test the SHA256 value of the download. The code is alongside the location of the download. For windows users the built in powershell has a File-hash function but it may be simpler to get an offline app from a reputable site.

The result must be exactly the same as given on the MiKTeX website.

If the SHA256 checksum is correct (confirming a valid signed file) then the next likely issue is the rights of the person installing versus the rights of the location you are installing to. Many users elevate themselves or their rights over folders to get around such "Access is Denied", Please avoid doing that as it is likely to cause other issues later.

First consider why the download is inappropriate for your rights. I would always recommend a simple one user portable install without any issues about maintaining dual controls. NOTE top answers to similar questions always recommend install as "Only for me" see "I strongly recommend to choose the user mode installation."
at Difference between administrative and user mode of MiKTeX

"single user installation is the best for a lot of people"..."90% of problems with map-files e.g. are due to misunderstandings regarding user/admin settings. "
from What is the preferable setup for MiKTeX to keep all packages up-to-date easily?

For recent 2018 advice on maintenance see Edit 2018: Windows and Linux at
How should one maintain and update a MiKTeX installation?

There has been a minor 2019 change in installation files for standalone users.

Consider downloading 32bit basic version or if you are confident your OS will always be 64bit then download that version as you download it save as miktex-portable.exe and check sha256 again matches current value on MiKTeX site.

"This works fine even if the user account has only restricted rights. There is no need to give this user admin rights or something similar. I simply log-in in the user account and install MiKTeX. Naturally the main texmf tree must be installed in a folder where the user account has the right to write."...

Failing the above raise an issue at https://github.com/MiKTeX/miktex/issues