Moving Users and Prog Files

If you’ve ever needed or tried to move the C:\Users directory or other default Windows® directories to another place other than the default one, you know it can be quite difficult.

I’ve tried to Google this, and talk to others about doing it. What seemed to be such a simple request also seemed to be difficult to pull off. That’s when a brilliant (nearly the smartest man I know) told me about hard links & junction links in windows. Think of them like symbolic links in Mac or *nix systems.

  • C:\dira linked to C:\dirb
  • D:\dir1\ to C:\dir2\dir3

The great thing about using hard links in Windows is that it acts as if the data is still there. In the example above, when you’re browsing C:\dira the system will act as if you’re really in that directory when in all reality you’re browsing C:\dirb. Even the address bar will show that.

Thanks to an almost 3-year-old post on Lifehacker, I accomplished what I thought was only possible with tons of registry tweaking and tons of time spent in Safe Mode with a potentially unstable system afterward.

Real Reason Why

So the real reason I needed to so this is that I wanted to totally rebuild my system. New parts, new paint. Start from scratch and make this new Windows 7 installation as fast as it could be. Thanks to a good friend, I was given a small 30GB SSD. Now I could have run Windows on this just fine and had some programs installed there and others installed on another disk. Maybe even copied my music, downloaded programs, etc… to this other disk. But that requires that every time an installer runs I have to pay close attention to where it’s going. Every time a program wants to move data into the “My Documents” folder, I have to be mindful that I’m only dealing with about 18GB free after a clean install. That’s simply not enough. I’d run out in less than a few weeks and many times probably forget that these installers are putting all their files into the C:\Program Files directory.

Step-By-Step

So here’s the step-by-step instructions to moving just about any folder to another disk, especially those special Windows ones.

Install & Create Restore Point

  1. Install a fresh copy of Windows 7 (or XP or 8, whatever you want)
  2. Dont do anything else. Just leave it fresh and clean.
  3. Create a Restore Point (just to play it safe)
    1. Right Click “My Computer” and choose Properties
    2. Choose “System Protection”
    3. Select the “System Protection” Tab
    4. Click Create
    5. Type a description for this Restore
    6. Click Create

System Recovery

  1. Boot back up with the install DVD
  2. Choose the appropriate language, currency & keyboard and click Next
  3. At the screen where there is a large “Install Now” button, look just below it and click “Repair your computer”
  4. You might be asked if you want to “Repair and Restart”, choose No.
  5. Make sure that the OS that system recovery found is the one you just installed and that it’s selected. Click Next.
  6. You’ll be presented with a few options…choose “Command Prompt”

Now here’s where we really get our hands dirty. Well, not really, but just a bit.

Find out which drives are what.

Install Drive: DVD
OS Drive: Source
Secondary Drive: Destination

On my computer, it was:

X: DVD Install Drive
E: Actual OS SSD Drive
D: Secondary Hard Drive

So at this point, you need to copy all the source data to the destination drive and create the hard links.

Using my drive letters above, here is how its done.

  1. robocopy /copyall /mir /xj E:\Users D:\Users
  2. robocopy /copyall /mir /xj “E:\Program Files” “D:\Program Files”
  3. robocopy /copyall /mir /xj “E:\Program Files (x86)” “D:\Program Files (x86)”

/mir tells Robocopy to mirror the directories. This will copy all files and their permissions
/xj is very important as well as it tells Robocopy to now follow any junctions points it might meet when browsing these locations. Don’t Forget This

Now as long as no files failed to copy, we can proceed.

In order to create junctions or hard links, the source folder must not exist. This means that we now have to delete those directories we just copied.

  1. rmdir /S /Q E:\Users
  2. rmdir /S /Q “E:\Program Files”
  3. rmdir /S /Q “E:\Program Files (x86)”

Now we create the NTFS Junction/symlinks

  1. mklink /J E:\Users D:\Users
  2. mklink /J “E:\Program Files” “D:\Program Files”
  3. mklink /J “E:\Program Files (x86)” “D:\Program Files (x86)”

Now you’ve just moved all three of these folders from the Windows system disk to another disk.

Prove it to yourself

Now comes the proof. Change directories to E:\. Type dir and see what you see. You should see ” Users [D:\Users]”

Now restart your computer and you’re done.

Congratulations!

Update

A while after doing this Windows Update started failing on a few updates. I kept receiving the following error: Windows update error 80070011

I found that Microsoft® isn’t following those symlinks properly when it comes to certain security updates. I think had I only moved the “Users” directory all would be fine.

Google is my friend and I found out what needed to change in order for security updates to continue.
Basically, there are a few registry keys you’ll need to point to the “real” location of the Program Files directory because it wont follow the junction link.

Make these changes to: HKEY_LOCAL\_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\

Key Name Old Data Value New Data Value
CommonFilesDir C:\Program Files\Common Files D:\Program Files\Common Files
CommonFilesDir (x86) C:\Program Files (x86)\Common Files D:\Program Files (x86)\Common Files
CommonW6432Dir C:\Program Files\Common Files D:\Program Files\Common Files
ProgramFilesDir C:\Program Files D:\Program Files
ProgramFilesDir (x86) C:\Program Files (x86) D:\Program Files (x86)
ProgramW6432Dir C:\Program Files D:\Program Files

After these changes are made, Windows should be able to update successfully.


TQuizzle

TQuizzle.com is my place to talk about whatever. I really don't post here much anymore what with all the other domains I own, but I'm putting it up on GitHub so that it can be seen for archive puposes.

comments powered by Disqus