# Changing the location of auto-installed packages in MiKTeX

This is a software question, specific to MiKTeX: I have automatic downloading of packages enabled, so that if I try to use a style that's not in the existing directory trees, it is downloaded from CTAN and installed. The problem is that MiKTeX installs it under %APPDATA% (at C:\Documents and Settings\<user>\Application Data\MiKTeX\2.9), which bloats my roaming profile. Is there a way to change this destination?

I already have another root for styles I install myself, but I can't get MiKTeX to use it for auto-installed packages. In the Roots list in MiKTeX Settings (mo.exe), the %APPDATA% folder has the tag "UserInstall". It won't let me edit or delete its path, or tag another root "UserInstall". Is there a way to do this, or am I stuck with rearranging the downloaded packages by hand afterwards?

-
I don't think that you can change UserInstall in a running miktex but it is possible to set it at installation time: docs.miktex.org/2.9/manual/setupwiz.html –  Ulrike Fischer Nov 12 '12 at 12:44
Great tip, thank you! –  alexis Nov 12 '12 at 14:13
I'm guessing this setting can probably be changed by editing the registry... but it was easy enough to re-install. –  alexis Nov 12 '12 at 14:28
Additional tip for a re-installation: Relocate MiKTeX 2.9?. –  Speravir Nov 12 '12 at 15:34
You could use Ulrike’s and my information and provide a self answer. –  Speravir Nov 12 '12 at 17:08

As Ulrike explained in the comments above, it seems that MikTeX allows the UserInstall directory to be configured only during installation. So, it's easiest to just re-install it, calling the installer from the commandline with suitable options. The full set of commandline options for the installer is documented here.
C:\...> basic-miktex-***.exe --shared --user-install="C:\Path\to\my\root"

I used --shared since it's being installed for all users, but I was asked again during the set-up dialog anyway. There are also options --user-config and --user-data (I don't mind leaving those in the default location).
I am just setting up a new computer, so this was a no-brainer. I follow best practices and keep all style files that are not managed by MikTeX in a separate texmf hierarchy, so there was no need to salvage anything before uninstalling. But if you have been dropping your non-CTAN styles into the MikTeX texmf tree (definitely not a good idea), or have a huge texmf tree and a slow internet connection, or use your computer off-line a lot and don't want to be surprised by missing packages, you can follow this procedure, which lets you use your old texmf tree as the data source for the new installation (thanks @Speravir for the pointer).