Having recently upgraded to Vista I decided it was high time to look at separating my user and program files from my Operating System. So I shifted around some files and formatted my D: drive in preparation for moving the files. I played with a few different methods for moving the user files including updating their Profile Path using the Users & Groups section in Computer Management but despite it working I felt this wasn’t what I was looking for so started looking at using Junctions to redirect my files instead. Ultimately through the use of a DOS Prompt and junctions I’ve moved all my user & program files off to my D: Drive. Here are the steps and information involved.
Windows Vista already uses several junction points which need to be replaced with our own ones. I have listed them here along with where they point to:
In the Root C:
Documents & Settings -> Users
In each User directory:
Application Data -> AppDataRoaming
Cookies -> AppDataRoamingMicrosoftWindowsCookies
Local Settings -> AppDataLocal
My Documents -> Documents
NetHood -> AppDataRoamingMicrosoftWindowsNetwork Shortcuts
PrintHood -> AppDataRoamingMicrosoftWindowsPrinter Shortcuts
Recent -> AppDataRoamingMicrosoftWindowsRecent
SendTo -> AppDataRoamingMicrosoftWindowsSendTo
Start Menu -> AppDataRoamingMicrosoftWindowsStart Menu
Templates -> AppDataRoamingMicrosoftWindowsTemplates
All users have the same Junctions in their user directories, including Default. There are two other Junctions created in the Users directory, these are:
All Users -> ProgramData
Default User -> Default
ProgramData is located is a directory in root C:.
As you can see there are numerous links to recreate. The reason why they are used is to provide backward compatibility with software designed explicitly for Windows XP that may have hardcoded the Documents & Settings directory or other directories within each User Profile. As a result you could try without them and any programs explicitly designed for Windows Vista should work perfectly as well as the majority of Windows XP programs but you may still run into issues. As its fairly simple to recreate the links its worthwhile doing.
The program that is used to create a link is called mklink and it is included with Windows Vista so no extra downloads are required for it.
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link refers to.
The majority of the folders we will be linking we will be using Directory Junction’s. This is roughly equivalent to a Hard Link. The usage is pretty easy to follow and if you have any trouble you’ll get a better idea of it in the nitty gritty of moving the files around.
Okay before rebooting what we’ll do is create a batch file which does everything for us. This is a lot easier than typing it all in at the command prompt and allows us to check easily for any missing parts. So open notepad.exe and we’ll get on with it. Just remember to replace any drive letters and other path issues that need to be different for your system.
The first part of the file is just creating the destination directories and then copying the files:
robocopy /XJ /MIR "C:Users" "D:Users"
robocopy /XJ /MIR "C:ProgramData" "D:ProgramData"
If you want to move your Program Files directory as well then include this bit:
mkdir "D:Program Files"
robocopy /XJ /MIR "C:Program Files" "D:Program Files"
Next we delete the original files off the C: Drive
rmdir /S /Q "C:Users"
rmdir /S /Q "C:Program Files"
rmdir /S /Q "C:ProgramData"
rmdir /S /Q "C:Documents & Settings"
Next we will recreate the user links:
mklink /J "D:UsersUserNameApplication Data" "D:UsersUserNameAppDataRoaming"
mklink /J "D:UsersUserNameCookies" "D:UsersUserNameAppDataRoamingMicrosoftWindowsCookies"
mklink /J "D:UsersUserNameLocal Settings" "D:UsersUserNameAppDataLocal"
mklink /J "D:UsersUserNameMy Documents" "D:UsersUserNameDocuments"
mklink /J "D:UsersUserNameNetHood" "D:UsersUserNameAppDataRoamingMicrosoftWindowsNetwork Shortcuts"
mklink /J "D:UsersUserNamePrintHood" "D:UsersUserNameAppDataRoamingMicrosoftWindowsPrinter Shortcuts"
mklink /J "D:UsersUserNameRecent" "D:UsersUserNameAppDataRoamingMicrosoftWindowsRecent"
mklink /J "D:UsersUserNameSendTo" "D:UsersUserNameAppDataRoamingMicrosoftWindowsSendTo"
mklink /J "D:UsersUserNameStart Menu" "D:UsersUserNameAppDataRoamingMicrosoftWindowsStart Menu"
mklink /J "D:UsersUserNameTemplates" "D:UsersUserNameAppDataRoamingMicrosoftWindowsTemplates"
mklink /J "D:UsersUserNameAppDataLocalApplication Data" "D:UsersUserNameAppDataLocal"
mklink /J "D:UsersUserNameAppDataLocalHistory" "D:UsersUserNameAppDataLocalMicrosoftWindowsHistory"
mklink /J "D:UsersUserNameAppDataLocalTemporary Internet Files" D:UsersUserNameAppDataLocalMicrosoftWindowsTemporary Internet Files"
mklink /J "D:UsersUserNameDocumentsMy Music" "D:UsersUserNameMusic"
mklink /J "D:UsersUserNameDocumentsMy Pictures" "D:UsersUserNamePictures"
mklink /J "D:UsersUserNameDocumentsMy Videos" "D:UsersUserNameVideos"
Replace Username with whatever the username you are working on is, just use Find & Replace in Notepad to fix it up. You need to use that piece of code for all users that you have added to your system. The code for Default is as follows:
mklink /J "D:UsersDefaultApplication Data" "D:UsersDefaultAppDataRoaming"
mklink /J "D:UsersDefaultCookies" "D:UsersDefaultAppDataRoamingMicrosoftWindowsCookies"
mklink /J "D:UsersDefaultLocal Settings" "D:UsersDefaultAppDataLocal"
mklink /J "D:UsersDefaultMy Documents" "D:UsersDefaultDocuments"
mklink /J "D:UsersDefaultNetHood" "D:UsersDefaultAppDataRoamingMicrosoftWindowsNetwork Shortcuts"
mklink /J "D:UsersDefaultPrintHood" "D:UsersDefaultAppDataRoamingMicrosoftWindowsPrinter Shortcuts"
mklink /J "D:UsersDefaultRecent" "D:UsersDefaultAppDataRoamingMicrosoftWindowsRecent"
mklink /J "D:UsersDefaultSendTo" "D:UsersDefaultAppDataRoamingMicrosoftWindowsSendTo"
mklink /J "D:UsersDefaultStart Menu" "D:UsersDefaultAppDataRoamingMicrosoftWindowsStart Menu"
mklink /J "D:UsersDefaultTemplates" "D:UsersDefaultAppDataRoamingMicrosoftWindowsTemplates"
mklink /J "D:UsersDefaultAppDataLocalApplication Data" "D:UsersDefaultAppDataLocal"
mklink /J "D:UsersDefaultAppDataLocalHistory" "D:UsersDefaultAppDataLocalMicrosoftWindowsHistory"
mklink /J "D:UsersDefaultAppDataLocalTemporary Internet Files" D:UsersDefaultAppDataLocalMicrosoftWindowsTemporary Internet Files"
mklink /J "D:UsersDefaultDocumentsMy Music" "D:UsersDefaultMusic"
mklink /J "D:UsersDefaultDocumentsMy Pictures" "D:UsersDefaultPictures"
mklink /J "D:UsersDefaultDocumentsMy Videos" "D:UsersDefaultVideos"
We also have the Public Directory to fix up links for:
mklink /J "D:UsersPublicDocumentsMy Music" "D:UsersPublicMusic"
mklink /J "D:UsersPublicDocumentsMy Pictures" "D:UsersPublicPictures"
mklink /J "D:UsersPublicDocumentsMy Videos" "D:UsersPublicVideos"
Now in the Users directory we have some links to create as well:
mklink /D "D:UsersAll Users" "D:ProgramData"
mklink /J "D:UsersDefault User" "D:UsersDefault"
And here are the other links for the root C:
mklink /J "C:Documents and Settings" "D:Users"
mklink /J "C:Users" "D:Users"
mklink /J "C:ProgramData" "D:ProgramData"
To include Program Files add this piece of code in as well:
mklink /J "C:Program Files" "D:Program Files"
That is the whole batch file completed. Now before you head off to run it make sure you double & triple check your paths, if you have made a mistake it could result in the loss of your personal data and/or program files. As an example of something that occurred while I was testing this. I had Vista already running in a VM so I booted that to test it, created a new drive which was assigned the driveletter E: which was fine so I modified my batch file copy all files to the E drive. Unfortunately unbeknowest to me when I restarted to get into the Command Prompt it reassigned my new drive to drive D so as a result it tried to copy all my user files to D: which naturally failed, the rmdir /Q /S makes it remove the relevant directories without any user interaction so before I knew it all the files were gone meaning I had to reinstall Windows Vista before running another test, with destination drive set to D:.
To run this anyway you just need to boot from your Windows Vista CD. Select to Repair a installation, select your Windows Vista installation and finally select Command Prompt. Then just navigate to wherever you stored it and run it by typing in the name.
There are a few issues with this method. One of the biggest is the way Windows Vista handles links still. Just like Windows XP it includes them in drive space usage checks. This can be quite annoying as ideally you want to shrink down the Windows Vista drive to a much smaller space since it doesn’t have your user files anymore and only Windows Vista files and Program Files(if you didn’t move them as well). This means that it will keep bringing up the message warning you of low disk space. Unfortunately with Windows Vista’s low disk space warnings there doesn’t appear to be a way to prevent it from checking a single drive. Rather its a all or nothing approach. To disable it you can follow the instructions here. Before doing so it may be a good idea to check this one out the warnings here.
Stay tuned for a proper script to ask questions and do it all for you on the fly.
A word of caution regarding moving your Program Files and ProgramData directories. Windows update will not function properly with them on a separate drive despite the use of hard junction points to link them to the new locations. Whilst there is a fix it is a time consuming one and requires you to make changes for every update that it can be applied to since it can only be applied to updates that require you to restart your computer. For more information you can search for the error code 0x80070011.