I am trying to set HOME to be %USEPROFILE% for the currently logged on user. However, creating a system environment variable HOME and setting to and setting it %USERPROFILE% does not seem to work. After logging out and logging in as a non-administrative user, I have

c:\ set
HOME=c:\Documents and Settings\administrator
HOMEPATH=c:\Documents and Settings\[user]

In the Windows Environment Variables dialog, I have


but don't see HOMEPATH anywhere. Can anyone tell me how to fix this?

  • How exactly do you set the HOME variable to USERPROFILE? It may have been litterally set to the string "%USERPROFILE".
    – user111228
    Jan 5, 2012 at 19:11
  • @hesse: The Environment Variables dialog adds registry values of type REG_EXPAND_SZ (as opposed to REG_SZ), allowing such expansion.
    – user1686
    Jan 5, 2012 at 20:10

1 Answer 1


It is a little unclear from your question, but it sounds like the problem is that the HOME environment variable is being assigned the expanded value of %userprofile% (c:\Documents and Settings\administrator) at time of configuring it, rather than being stored as the string literal %userprofile% which would be expanded after login.

It's been a while since I worked with this sort of thing on XP, bu if I recall, permanent environment variables are stored in the registry.

set usually only works in the current cmd session, so to get it to be across all sessions,there is a setx util (from Microsoft) that will permanently set env variables.

One trick is to make a batch file which runs at startup (put it in the startup folder of all users) which runs setx. This will ensure that %userprofile% expands to the currently logged in user's profile.

  • Just wanted to add that BATCH files are simple script files having the extension .bat. Simply put the commands you normally run in cmd in this file and when executed, all the commands will run as if you ran them from cmd.
    – user111228
    Jan 5, 2012 at 20:18
  • @horatio I would the value of HOME to be set to the the location of the currently logged in user's profile directory is (ie value of %USERPROFILE%). Does that make sense?
    – Azim
    Jan 5, 2012 at 20:39
  • @horatio the batch file work around does not work either. Testing indicated that HOME is being set to the previous logged-in user's %USERPROFILE%.
    – Azim
    Jan 5, 2012 at 20:48
  • You would be setting the value of HOME every time a user logs in. If HOME is set, you might need to unset it first not sure, and you will need to SET it in such a way that it stays SET until logging off. Normally, any environment variables created using SET will go away as soon as the cmd window (or batch file process) is closed. Setx works around this. see, for instance ( ss64.com/nt/setx.html )
    – horatio
    Jan 5, 2012 at 21:54
  • @horatio thanks for the clarifications. I was originally setting HOME using Windows Environment Variables dialog box (under System Properties -> Advanced ->Environment Variable). I also tested your suggestions of a BAT file in All Users->Startup folder with the single line setx HOME=%USERPROFILE%. Both seem to set HOME to the previous logged in users profilfe directory.
    – Azim
    Jan 6, 2012 at 19:18

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.