Manually relocating the Windows 7 User Profile Folder


WARNING: Please read before continuing ▼

Difficulty: Expert
Time: ~30 Minutes
Last Updated: 8th October 2009
Applies to: Windows 7 ONLY

Relocating the user profile folder is a procedure that can make backing up massively easier. User specific data, such as music and videos, can be moved to another drive, leaving only the core OS and programs on the primary hard drive. It can also act as a cost saving measure, using a small, fast, expensive drive to install the OS to, and a slow, but big and cheap drive to store user data.

N.B. While this procedure was written with Windows 7 in mind, it should also work with Windows Vista, if you substitute in the correct paths and filenames. It is not likely to work on Windows Vista unmodified.

Abstract:

This should only be attempted on a fresh installation of Windows 7, before any user data has been added. This procedure will relocate the user profile folder, it will not relocate existing user data. If you attempt this on a machine with existing users, it is likely that they will be unable to log back in.

If you do manage to relocate existing data, then it is likely that poorly written programs that rely on the location of the user profile folder not moving since installation. This will also be an issue if you are using a pre-built install image, such as those provided by Dell/Asus.

I will assume that you are moving the User Profile Folder to D:\Users, though you can move it to anywhere you like, just substitute D:\Users for the location that you want to use.

As this procedure is rather complicated, I will assume that the reader is familiar with certain tools, such as mklink and icacls. I will also gloss over the actual implementation of items such as copying files. If any section of this guide is unclear, please seek further assistance.

A better way:

The MS recommended, and frankly better way to do this is using the Windows Unattended Install Kit (WAIK). The WAIK is not a particularly easy tool to use, and the learning curve required to be able to create an install disk is quite high. This method is simpler, and the results are nearly the same. Nevertheless, if you have the WAIK and know how to use it, you should do so.

Procedure:

To start off, create a temporary user with administrator priviliges, reboot the computer into safe mode (no networking needed) and log into that user.

Then, create a second temporary user, but DO NOT LOG IN WITH THAT USER. If you log in to that user account, delete it and create another.

Then, create the folder that is to house the profiles, i.e.:

C:\> D:\
D:\> mkdir Users
D:\> dir
Directory of D:\.
.             <DIR>           20-10-2009 00:00
..            <DIR>           20-10-2009 00:00
Users         <DIR>           20-10-2009 00:00
0 File(s)Â Â Â Â Â Â Â Â Â Â Â 17,712 Bytes.
1 Dir(s)Â Â Â Â Â Â Â 262,111,744 Bytes free.

Next, copy C:\Users\Default to D:\Users\Default, and C:\Users\Public to D:\Users\Public. If any files cannot be copied, it is probably safe to leave them.

Next, fire up regedit.exe and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList, and change the values as follows:

Default should have the value changed to D:\Users\Default
Public should have the value changed to D:\Users\Public
ProfileDirectory should have the value changed to D:\Users

At this point, you need to reboot your computer. Load it in safe mode (no networking) again, and log in as the second temporary user.

Now, copy everything from C:\Users to D:\Users. During this copy, there will be some files that cannot be copied. If they are .tmp files, it is safe to skip them. Beyond that, you will have to use your own judgement. If, as recommended, you are doing this on a fresh installation, there should be no problems skipping every un-copyable file.

While this is going on, open regedit.exe and search for “C:\Users“. If you find a key, update its path or delete it. Again, which should be done is left to the readers judgement as there is no constant rule; it depends on the system.

Next you need to fix the NTFS Symbolic Links and Junctions used for Vista/XP compatibility. To do this, delete the old Junction Points and use the mklink command to repair them.

mklink /j “C:\Documents and Settings” D:\Users
mklink /j %ProgramData%\Desktop D:\Users\Public\Desktop
mklink /j %ProgramData%\Documents D:\Users\Public\Documents
mklink /j %ProgramData%\Favorites D:\Users\Public\Favorites
mklink /j “D:\Users\Default User” D:\Users\Default
mklink /j “D:\Users\All Users” C:\ProgramData

Once you have done this, the process is effectively complete; you can reboot, create a regular user and delete the temporary ones, then erase C:\Users\

For maximum compatibility though, you need to set the permissions properly on the junctions you have just created. These commands should be executed in the order given:

attrib +s +h “C:\Documents and Settings”
icacls “C:\Documents and Settings” /grant:r System:(F) /inheritance:r
icacls “C:\Documents and Settings” /grant *S-1-5-32-544:(F)
icacls “C:\Documents and Settings” /grant *S-1-1-0:(RX)
icacls “C:\Documents and Settings” /deny *S-1-1-0:(S,RD)

attrib +s +h “%ProgramData%\Desktop”
icacls “%ProgramData%\Desktop” /grant:r System:(F) /inheritance:r
icacls “%ProgramData%\Desktop” /grant *S-1-5-32-544:(F)
icacls “%ProgramData%\Desktop” /grant *S-1-1-0:(RX)
icacls “%ProgramData%\Desktop” /deny *S-1-1-0:(S,RD)

attrib +s +h “%ProgramData%\Documents”
icacls “%ProgramData%\Documents” /grant:r System:(F) /inheritance:r
icacls “%ProgramData%\Documents” /grant *S-1-5-32-544:(F)
icacls “%ProgramData%\Documents” /grant *S-1-1-0:(RX)
icacls “%ProgramData%\Documents” /deny *S-1-1-0:(S,RD)

attrib +s +h “%ProgramData%\Favorites”
icacls “%ProgramData%\Favorites” /grant:r System:(F) /inheritance:r
icacls “%ProgramData%\Favorites” /grant *S-1-5-32-544:(F)
icacls “%ProgramData%\Favorites” /grant *S-1-1-0:(RX)
icacls “%ProgramData%\Favorites” /deny *S-1-1-0:(S,RD)

attrib +s +h “D:\Users\Default User”
icacls “D:\Users\Default User” /grant:r System:(F) /inheritance:r
icacls “D:\Users\Default User” /grant *S-1-5-32-544:(F)
icacls “D:\Users\Default User” /grant *S-1-1-0:(RX)
icacls “D:\Users\Default User” /deny *S-1-1-0:(S,RD)

attrib +s +h “D:\Users\All Users”
icacls “D:\Users\All Users” /grant:r System:(F) /inheritance:r
icacls “D:\Users\All Users” /grant *S-1-5-32-544:(F)
icacls “D:\Users\All Users” /grant *S-1-1-0:(RX)
icacls “D:\Users\All Users” /deny *S-1-1-0:(S,RD)

After this, the process really is complete. Create yourself a regular user, reboot and log into it, and delete the 2 temporary users you made and C:\Users\

Sources and Further Reading:

Microsoft KB 968178 When you use the System Preparation Tool (Sysprep) or Windows Vista Setup to apply the FolderLocations unattend settings, some system directory junctions do not point to the new target location
Microsoft KB 929831 A description of known issues with the FolderLocation settings in the Windows Vista Unattend.xml file
Microsoft KB 949977 Relocation of the Users directory and the ProgramData directory to a disk drive other than the disk drive that contains the Windows directory on a Windows Vista-based or a Windows Server 2008-based computer
MSDN Application Compatibility Junction Points and Backup Applications

, , ,

  1. #1 by NoName on Wednesday June 15, 2011 - 10:22

    You need to add “/L” Switch for attrib otherwise attrib will work on the link destination instead of the link itself.

    Administrator’s Edit: This guide uses NTFS junctions, not symbolic links. When using junction points, the /L switch is not required.

  2. #2 by NoName on Wednesday June 15, 2011 - 11:09

    And icacls also needs the “L” switch!

    Administrator’s Edit: This guide uses NTFS junctions, not symbolic links. When using junction points, the /L switch is not required.

(will not be published)


Technical Procedures is Digg proof thanks to caching by WP Super Cache