Sunday, September 19, 2010

User environment variables in windows

I’ve been running as a normal user under windows which has required a change to my emacs setup. By default if you don’t have a HOME variable defined, windows looks under the root directory for .emacs.d and .emacs initialization files. As an administrator this isn’t an issue, but as a user those files are inaccessible. I needed to set the HOME variable to point to the user directory so emacs could read its initialization file.

The normal way to edit environment variables is to right click on “Computer” and click on “Advanced system settings”. Then click on “Environment Variables” under the Advanced tab. Unfortunately this requires administrative privileges and you can only set the administrators environment variables.

To set a users environment variable you have to do it via the command prompt. To set HOME you would do something like this:

setx HOME “Your value here”

or in my case:


You’ll have to restart the command prompt for the value to take effect.

To access the variable on a command prompt:

echo %HOME%

And in powershell:

echo $env:HOME