You are here

Windows 7: Moving your user profile to another directory/partition/drive

Submitted by Druss on Tue, 2012-02-21 22:34

Continuing on with my workarounds for moving system files around, today, I decided to look into moving my user profile folder to a different partition. While IIRC, it used to be possible (in earlier versions of Windows) to do this by setting the home folder to an appropriate value in the user management snapshot, that did not work for me.

Searching on the net came up with a lot of nonsense, solutions with registry modifications and so on. A little more digging later, I came across this immaculate solution which also introduced me to the robocopy and mklink commands which I'm guessing were introduced in Vista. While it worked like a charm, I do want to repost the solution here with a couple of caveats which might make things difficult for the inexperienced. I've also expanded some of the steps in the interest of completeness.

  1. If your files and settings are precious to you, then prior to doing anything, back up everything in your profile folder and indulge in all the precautionary steps you can think of.
  2. Enable the administrator account for your PC using the following steps:
    1. Go to your control panel and click on Administrative Tools.
    2. Within, double-click on Local Security Policy.
    3. In the resulting window, expand Local Policies and then select Security Options.
    4. The first option that should come up in the list of options on the right should be one titled Administrator account status. Double-click this option.
    5. In the ensuing dialog, select Enabled and click on OK.
    6. The User Accounts management control panel should now allow you to set a password for the now visible Administrator account. Setting a password is recommended, even if we are only going to be using this account temporarily.
  3. We are going to assume that the source profile folder is located at C:\Users\Foo. Since we are going to be moving stuff around it's best to keep things slim and tidy. To this end, clear all your browser caches, windows temporary files and so on for this profile.
  4. In the target location, create an appropriate folder. In this example, this location is going to be G:\Users\Foo.
  5. Log out and log back in as the administrator.
  6. To avoid situations in subsequent steps where active services are denying access to files in the profile folder, it is best to disable some of the services running. This step might be optional for some.
    1. Go to your control panel and open Administrative Tools. Within, double-click on Services.
    2. To easily access running services, click on the Status column header a couple of times to sort the list of services based on their current status.
    3. In my case, I had to stop the Windows Media Network Sharing service. To do so, right click on it and click on Stop. While I was here, I decided to also disable other tell-tale services that I thought might interfere with the operation. I went ahead and also disabled the User Profile Service. These stoppages are temporary and these services will resume after a reboot.
  7. In the Start Menu's search field, type cmd and select cmd.exe.
  8. Here type robocopy /MIR /XJ   C:\Users\Foo  G:\Users\Foo . This will take a while to complete. If you run into access denied errors, you might need to disable a running service as outlined earlier.
  9. Once this is done, check that the copy operation has gone through successfully. You can now either rename or simply delete the current profile directory at C:\Users\Foo .
  10. Now, we can create the Windows equivalent (junction) of a Linux symlink by typing mklink /J C:\Users\Foo  G:\Users\Foo . This should point the default location for the profile directory to our new location and Windows will be quite oblivious to it.
  11. Once this is done, close all windows and reboot the system.
  12. Log in as Foo and you should find that the profile looks just the same as before except that now it resides in a custom location.
  13. If everything is well, remember to go and disable the Administrator account created during the initial stages!

I hope that this helps somebody out there!

Comments

This process works well overall.
I did some things slightly differently to overcome the missing bits in 'Home' editions...

Instead of step 2: As I was working on win7 home (ditto for vista home) the Local Security Policy editor (secpol.msc) was not available. The user account I had to move had admin status so I used it to create another account 'admintemp' with admin status and a password.
Instead of step 5: Re-started and booted into safe mode (actually the F8 key refused to work - instead use run -> msconfig - bootmode settings, see http://helpdeskgeek.com/windows-7/safe-mode-f8-doesnt-work/ ).
I logged in using the 'admintemp' account. This means minimal services were running.
So at step 6.3: The only service that I had to stop the 'User Profile Service'.
I then followed the rest of your process with robocopy and creating the mklink junction. I then deleted the 'admintemp' account when all was done.

p.s. This was actually harder than it sounds because I was doing this on a Chinese Windows 7 machine but I can't read Chinese! Unfortunately you cant just change to English using the home edition either. Fortunately I had a Vista English machine to help me compare but there were some interface differences. Note also, the command line uses English and does recognise "Users" in place of its Chinese equivalent so the mklink junction still works fine as per the instructions above. The moved user account worked fine when I logged back in to the regular windows desktop with moved user account.

Chinese W7 Home? You have both my deepest sympathies and sincere admiration :) Thanks for the detailed note. I'm sure there will be a number of people who are going to find it handy!