# Script to Setup Windows for already-installed Miktex

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.

Update:

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).

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. Jan 17 '17 at 19:35