# How to change the MATHEMATICA_USERBASE directory

I’ve found, from reading the help on MathKernel in the help system and in a number of questions here, that to make that change in Windows at least one apparently needs to enter “MathKernel … options” in a “Command Prompt” window. Which works, at least partly, but the MathKernel documentation is notably lacking in specifying the syntax required. I’ve tried (along with several similar ones) the following:

1. MathKernel MATHEMATICA_USERBASE= D:\WorkB\Mathematica,
2. MathKernel MATHEMATICA_USERBASE D:\WorkB\Mathematica, and
3. MathKernel MATHEMATICA_USERBASE->D:\WorkB\Mathematica

The first two “work” in that a Kernel window opens, but querying $UserBaseDirectory in the Kernel window indicates that that directory has not been changed from the default (C:\Documents and Settings\User\Application Data\Mathematica). And the third one produces an “Access is denied” message in the Command Prompt window, but I don’t know whether that was due to the Command Prompt or to the MathKernel complaining about the syntax or the operation itself. So, what is the syntax required to change that environment variable through the MathKernel command? Which is apparently the recommended or required procedure according to Wolfram. Or, is there another way of doing that? - It says: "The value of $UserBaseDirectory can be specified by setting the MATHEMATICA_USERBASE operating system environment variable when the Mathematica kernel is launched. It cannot be reset from inside the kernel." So, do it the same way as you would set any other environment variable. In case you don't know how the Windows command prompt works, that is: set MATHEMATICA_USERBASE=D:\WorkB\Mathematica, then run MathKernel. – Oleksandr R. Jan 15 '14 at 3:09
@Oleksandr R. – thanks for the suggestions. That does work, although only for the MathKernel called from within the particular Command Prompt in which that “Set” command is issued. However, I also found out that the “System” dialog in the Control Panel [Advanced/EnvironmentVariables] allows one to create a MATHEMATICA_USERBASE variable in the User section and set the Value parameter accordingly. Every MathKernel and FrontEnd subsequently opened in the normal manner returns the correct and changed value for $UserBaseDirectory. Thanks again. – Steersman Jan 15 '14 at 9:01 @steersman Could you put that in an official answer so that others can find it as well? Note that self-answering is fine here. – Sjoerd C. de Vries Jan 15 '14 at 12:00 @Sjoerd Yes, thanks for the suggestion and confirmation, and will do – I tried to do that last night after Oleksandr’s comment but found that someone posing a question needs to wait a minimum of 8 hours to answer it themselves – an interval that hadn’t yet then lapsed. – Steersman Jan 16 '14 at 5:50 ## 1 Answer There seem to be at least two ways of changing the MATHEMATICA_USERBASE directory variable, at least in the Windows XP environment, each of which has its own uses, and two of which follow: 1. • Open a “Command Prompt” window; • issue a “Set” command: Set MATHEMATICA_USERBASE=D:\WorkB\Mathematica, for example; • Open MathKernel within the Command Prompt window with: C:\”Program Files”...\MathKernel; • issue the command$UserBaseDirectory in the new Kernel to confirm that the directory has been changed as specified;
• note that this only works for the MathKernel called and opened from within the Command Prompt window

2.

• Select the “System” program in the Control Panel;
• navigate to “Advanced”, and select “Environment Variables”;
• in the “User variables for User” listbox area select “New” and create a new MATHEMATICA_USERBASE variable and then set the variable value to the required directory;
• open directly either the MathKernel or the Mathematica front end from their “Program Files” directory, or the latter at least from its Windows link;
• issue the \$UserBaseDirectory command and confirm that the directory has been changed accordingly;
• note that this variable is changed for every instance of the program without any further requirements;
• note also the first time the Mathematica front end is opened thereafter, it creates several subdirectories there including \SystemFiles\FrontEnd\StyleSheets, the latter of which was what I ultimately required – a place to put custom style sheets applicable to the projects I was working on.
-