Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Current, the home of current user is:

C:\Documents and Settings\freewind

It contains many other directories, e.g. My Documents, Desktop

Now I want to move the whole directory to another place, for example:

D:\freewind

Then if I want to run this Java code:

System.out.println(System.getProperty("user.home"))

It will print D:\freewind.

Is it possible?

share|improve this question
2  
Here's a fairly long description, might be helpful. But it depends on what you really need. Java only reads the %USERPROFILE% environmental variable. –  slhck Sep 6 '11 at 20:36
    
@slhck, it's long, but it's I expected :) Please copy your comment as an answer, so I can accept it. –  Freewind Sep 6 '11 at 20:57
add comment

2 Answers

up vote 3 down vote accepted

Java uses the %USERPROFILE% environmental variable, but if you want to move the home directory to some other folder or other drive, this is a bit tricky.

Here is a very well explained blog post about how to move the Windows User Profile to another directory, written by Keith Survell.

The idea is to use NTFS junction points. Here are the basic steps:

  • Make a thorough backup
  • Create a second user account and log into this one
  • Move the complete user's directory contents to the new folder, e.g. from C:\Users\JohnDoe to C:\JohnDoe. This can be done by just drag/dropping in Windows Explorer.
  • Rename the old User directory to something else (e.g. JohnDoe.old)
  • Open the command prompt and enter

    mklink /J C:\Users\JohnDoe C:\JohnDoe
    
  • Log out of the temporary user profile

Keith appears to like Super User. I couldn't find you though. If you're reading this, please feel free to expand or comment!

share|improve this answer
    
I'm not hard to find ;-) I'm glad people still find that article helpful! –  Keithius Mar 26 '12 at 12:10
add comment

If you run lusrmgr.msc, you can change the user profile location. Select a user in Users, right click and click "Properties". Then go to "Profile" tab. By default, the "Home folder" has an empty Local path (which is really C:\Documents and Settings\username). Just put the new path in it.

share|improve this answer
    
I have tried of this, but it doesn't work. After rebooting, all my programs will still treat "C:\Documents and Settings\freewind" as the user home. –  Freewind Sep 7 '11 at 5:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.