Moving Windows 7 User Profiles during Installation

I am one of those guys that prefer to separate my user data from the operating system data, and in this post I am going to show you how I install user profiles on an alternate drive during a Windows 7 installation.

There are many ways to achieve the same result, such as using post build scripts and the like, however this is sufficient for what I would like to achieve.

I am going to skip the initial steps of the Windows 7 installation. I am starting from the first user interface prompt where Windows 7 asks you for a user name for your account and allows you to name your computer.

 

image

Fig 1. Select a user name and name your computer

When you reach this screen, DO NOT PROCEED ANY FURTHER. The next step is to modify some of the Windows 7 defaults which can be done using the command line.

Action: Press SHIFT + F10 – this will open the command prompt seen in Fig 2.

 

image

Fig 2. The windows command prompt

The next step is to open the Computer Management Console and to configure the local hard drives.

Action: Type “compmgmt.msc” at the command line and hit ENTER

 

image

Fig 3. The Computer Management Console

This is the place where you manage almost all aspects of your computer. The part we are interested in is the “Disk Management” console.

Action: Select the “Disk Management” option from the left hand pane.

 

image

Fig 4. The standard disk management console for a new installation of Windows 7

Action: Arrange your hard drives and allocate drive letters are required.

 

image

Fig 5. The disk management console with the hard drives prepared and drive letters applied

Action: Close the computer management console and return to the command prompt.

 

image

Fig 6. Back to the command prompt

We have prepared the hard drives and partitions, and they are ready for us to change the Windows 7 defaults. The next steps are to copy the default files and folders from the C:\ drive to the D:\ drive or any other drive or partition that you would prefer to use.

We are going to be using Robocopy, an XCopy tool that is built into Windows 7, to copy the directories.

Actions:

  1. Copy the Users directory from C:\Users\ to D:\Users\
    Enter the following command at the command line to achieve this:
    Robocopy.exe C:\Users D:\Users /E /COPYALL /XJ
  2. Copy the ProgramData directory from C:\ProgramData\ to D:\ProgramData\
    Enter the following command at the command line to achieve this:
    Robocopy.exe C:\ProgramData D:\ProgramData /E /COPYALL /XJ

Notes:

For a full listing of the Robocopy switches, please visit: Robocopy Syntax, Command Line Switches and Examples.

 

image

Fig 7. The results of the Robocopy commands being executed

 

image

Fig 8. Open the Windows 7 Registry Editor

Action: Type “regedit” at the command line and hit ENTER

 

image

Fig 9. The Windows 7 Registry Editor

Action: Navigate to the Windows 7 Profile List Registry Settings

Steps:

  1. Locate the “ProfileList” in the following location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  2. Update the following 4 registry settings from %SystemDrive% to D:\ (If you have chosen to use the D:\ drive as the new location)
    1. Default – D:\Users\Default
    2. ProfilesDirectory – D:\Users
    3. ProgramData – D:\ProgramData
    4. Public – D:\Users\Public
  3. Reboot the machine by running the following command
    shutdown /r /t 0

The reason for the reboot is to allow Windows to relocate its temporary ProgramData files into the new location.

 

image

Fig 10. Remove the original Windows directories

Now that Windows 7 has been restarted, it should have moved its ProgramData files to the D:\ Drive. It is now time to remove the C:\Users and C:\ProgramData directories.

Action: Remove C:\Users and C:\ProgramData

Steps:

  1. Remove C:\Users by running the following command:
    rmdir C:\Users /S /Q
  2. Remove C:\ProgramData by running the following command:
    rmdir C:\ProgramData /S /Q

 

image

Fig 11. Unable to remove a directory due to locked files

You will not necessarily come across this step, however if you do, try another reboot.

Action: Reboot the machine by running the following command: shutdown /r /t 0

 

image

Fig 12. Create file system junctions to handle dodgy software

Junctions allow older software with hard coded paths to still operate once you have moved your profile data by acting as a pointer and allowing C:\Users to still appear valid even though the data is now on the D:\ Drive.

Action: Create junction for C:\Users and C:\ProgramData

Steps:

  1. Create the C:\Users junction by running the following command:
    mklink /J C:\Users D:\Users
  2. Create the C:\ProgramData junction by running the following command:
    mklink /J C:\ProgramData D:\ProgramData
  3. Reboot the machine by running the following command
    shutdown /r /t 0

 

image

Fig 13. You are now back at the Select a user name and name your computer

Action: You are now free to create a user name, name your computer and then log in once complete.

 

image

Fig 14. Logged in to the newly built Windows 7 machine

The junctions that you created above are visible in the root of the C:\ drive, and when you click on them it appears as if the files are on the C:\ drive, however they are really on the D:\ drive.

 

I hope this helps a few of you, especially if you have been stuck in the past trying to move C:\ProgramData to another drive.

9 thoughts on “Moving Windows 7 User Profiles during Installation

  1. hope this works. I’m trying it now. I tried the “unattended” route using sysprep, but it would crap out near the end (after audit mode was turned off). Thanks for the info.

  2. Generally I don’t read post on blogs, but I wish to say that this write-up very forced me to take a look at and do so! Your writing style has been surprised me. Thanks, quite nice article.

  3. I was looking for this the other day actually. I will now do a re-install because all of the other methods of doing this sort of thing never seem to work or they work only *somewhat* and by this I mean I had to leave at least one user with privileges on on the C:Users\
    However your way is the correct way because from the WindowsPE environment you don’t get the file locking. Not only that but people would be surprised after initial boot and configuration just how many system reliant processors actually get hard coded with the User directory,
    This method takes most emphasis off the symlink and more on using the correct hard code into the registry (not hacks that get done later with *unknown* amounts of them locked out due to file locking inside the registry) and alternatively keeps the symlink there *just* for older apps that have hardcoded to look in C:Users\
    instead of reading from the registry, There isn’t many apps around like this nower days but it is good to have the symlink only there for when this occurs.

    Now….I only have to share with you a write up on how to recover your old registry to allow your Programs to run again without re-installation 😉 People have said that it cannot be done but I have got this working before. I will send you a link if I ever do a write up.

    Thanks for sharing!

  4. Great guide.

    I needed to set up a Win 7 Pro laptop like this once I acquired an SSD. This did the trick.

    Thank you.

  5. Here is one another option to recover data from windows vista and windows 7, Kernel for windows data recover software to repair damaged partition and recover complete data files from windows drives. The software support every vision of MS Windows 8, Windows 7, Windows Vista, Windows XP, Windows 2003, Windows 2000, Windows 98, Windows 95, and DOS.

  6. Spot on sir. This technique worked great.

    I didn’t know about the command prompt from install trick. I’m bookmarking your post.

    Great documentation.

  7. A word of caution for the Windows8 folks. While this procedure works perfectly, it breaks the windows 8 upgrade and you will be stuck.

Comments are closed.