The problem:

I have Miktex installed in a directory on a non-system drive. I frequently do clean reinstalls of Windows (I have a few machines). This wipes out all the settings, including Miktex's from Windows.

What I want to do: Run a script that adds all the paths, settings, whatever, back into the registry/settings so that Mixtex (and WinEDT) work correctly WITHOUT running the full installer which requires me to wipe out the old directory and start over, download packages, etc.


I have switched to the portable version of Miktex. All that is required to run everything is to add the Miktex path (say C:\Miktex\install\miktex\bin) to the existing path variable.

I previously used the installed version like you, but I now prefer this system because it can be easily backed up and transferred to another computer or just run off a USB drive.

If you switch to the portable version, you can transfer the existing packages that you already have installed across to the portable version using the commands (put them in a batch file to make it easy)

mpm --verbose --repository="c:\currentmiktex" --import-all
initexmf --mkmaps
initexmf -u

where, for example, c:\currentmiktex is the directory of the installer version of Miktex.


Here is an example. I deliberately deleted the storebox package from my portable Miktex installation on the c: drive. My backup copy on the USB i: drive still has this package, so that is the only difference between the two installations. When I run the batch file, it gets storebox from the i: drive (see picture). batch file output

My path variable includes c:\miktex\install\miktex\bin where all the Miktex executables live (this is permanently set up before calling the batch file). The repository should point to where the other Miktex files are (in my case the portable backup i:\miktex\install). See the picture for some of the directories under this directory.


I hope this helps.

  • Ok, I made a batch file with those three lines (preceded by the directory to the \bin\x64\ files). The second command failed with "The config file could not be found." I think your answer assumes that I have a working already-installed/registered copy? I have the full miktex directory, but it is now sitting on a clean copy of windows, so nothing in the %userprofile% or %appdata% or program files directories has been set up.
    – JKreft
    Jan 17 '17 at 19:35
  • @JKreft It works for me. Please see additional comments in my answer.
    – user41974
    Jan 18 '17 at 3:02
  • Ok, from your edited description, it sounds like the script will handle creating a new portable setup from an existing one, but I don't have an existing portable setup. I have an "installed" miktex directory, but with none of the windows-side parts that were installed at the time. I'm going to try putting the path addition in the batch file to see if that fixes the problem, but since the config file it is missing isn't there, I'm guessing it won't.
    – JKreft
    Jan 18 '17 at 17:56
  • @JKreft It should work for both versions. When I used the "installer" version and wanted to upgrade or reinstall Miktex, the steps were 1. Copy existing Miktex directory to new drive (eg a USB). 2. Uninstall Miktex using control panel (using the thorough cleanup option). 3. Install new version of Miktex. 4. Use the batch file to reinstall packages from copied version of Miktex on new drive. 5. Delete Miktex on new drive. I think the problem is with the path. I suggest you permanently add the new Miktex path to your system path. You need this anyway to run the portable version.
    – user41974
    Jan 19 '17 at 0:54
  • Ok, so I'd still need to run at least the basic installer with your steps. I'm looking for a script to do this without needing to run the installer. I've put together a series of batch and reg files to configure my system using existing pieces after a system drive wipe (which I do regularly on multiple systems), and I wanted this to be one of them.
    – JKreft
    Jan 19 '17 at 2:13

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.