Hi! Welcome to Angry Cat Productions. If you have any questions about any of my posts, comment, and I'll do my best to help in a timely fashion (usually quite quickly.) If you have any other questions, feel free to comment on whatever post you want, and I'll take a stab at helping you out. And if something on this site helps you solve your problems, please let me know in a comment. Because like the rest of the world, I like warm fuzzy feelings. Enjoy!

Angry Cat Productions

Monday, July 09, 2007

Moving or Changing your Documents and Settings and Program Files directories to a different partition on Windows XP

Otherwise known as "The next installment of my installation saga, tuned to search engine hits".

Well, I had this big fancy walkthrough on how to do this during the Windows install so it would be nice and clean and easy. And it would have been - but I couldn't get it to work. I may have been more successful if I had a floppy drive, but I don't. So I had to do it the messy way - which actually ended up pretty clean in the long run. Here's about how it went down.

First, I installed Windows XP normally - plain vanilla, standard install. The key to doing things the 'messy' way is to install as little as possible before you go around messing with things. I would highly reccommend grabbing John Haller's portable apps suite, putting it on your flash drive, and running what you need off of that (for example, Portable Firefox to bring up this blog, or any how-to pages or downloads). I made the mistake of installing Firefox and my wireless driver first - which caused some annoying problems, especially the Intel wireless, which I'll go into down below.

Firstly, if your wireless doesn't work becuase of a driver, I would reccommend plugging into ethernet somewhere for now. If your LAN port doesn't work (unlikely), use another computer to pull up the how-to pages. Copy any needed files over on a flash drive. Once again, the key here is to avoid adding ANYTHING to your computer until after you get this taken care of. A squeaky-clean windows install is what you want.

I started with a nice post over at WinForums that, while I'll be doing most of the replacing myself, gives a nice procedure on when to do it. Oh, and to do the replacing, you'll need either a lot of free time and a good measure of masochist tendencies, or a registry-replace program. I'd reccomend going with the second option. I used RegReplace, a C++ freeware program. I don't know of its merits versus other programs available, but it worked fine for my purposes. Don't let its command line interface scare you away, it's very simple.

So, to get this thing started, follow the first few steps on the WinForums post:

  1. Login as administrator
  2. Create a backup copy of your registry - this is very important, you can screw up all kinds of stuff messing with your registry, and you'll need a backup in case you do. To do so, go Start->Run (Windows Key+R) and type 'regedit'. Click on "My Computer" and select File->Export. Save it somewhere safe, preferably off-disk, such as a flash drive. it will be somewhat large, my fresh Windows install was about 25MB, yours will probably be similar. Just make sure it's somewhere around there.
  3. Create a new user (Start->Control Panel->User Accounts) as an administrator, call him (or her) "temp" - you won't need the account for long.
  4. Log out of Administrator
  5. Log in as temp
  6. Create your target folders - I did it the hard way and renamed my folders as well, so I'll be using D:\ProgDir for Program Files and D:\Profiles for Documents and Settings. You can use whatever you like. Just replace any mention of D:\ProgDir and D:\Profiles with whatever you chose. In any event, you'll need to create them wherever they belong - I went to D:\ and just created a couple folders and named them ProgDir and Profiles.
  7. Now it's time to get our hands dirty. Bring up a command prompt and cd to the location that you downloaded regreplace.exe. For example, if it's on your flash drive at E:\Downloads, you would do something like the following:
    C:\Documents and Settings\temp\>E:
    E:\>cd Downloads
    Now, time to run the regreplace. You specify what to search for by adding /S "String to find" after the exe, and /R "String to replace with" after that. For example:
    E:\Downloads>regreplace.exe /S "C:\Documents and Settings" /R "D:\Profiles"
    E:\Downloads>regreplace.exe /S "%systemdrive%\Documents and Settings" /R "D:\Profiles"
    E:\Downloads>regreplace.exe /S "C:\Program Files" /R "D:\ProgDir"
    Now, there will be a bunch of status messages between those letting you know that it's replacing stuff. That's just fine - let it do its thing. There are a few things we did here:
    • Replaced references to C:\Documents and Settings with our new path (D:\Profiles in my case)
    • Replaced references to C:\Program Files with our new path (D:\ProgDir in my case)
    • Most strangely, replaced references to %systemdrive\Documents and Settings with our new path (D:\Profiles in my case). %systemdrive% is an environment variable that contains the drive that the Windows dir is on. Environment variables are basically placeholders that can be used all over the system for various often-used paths, like the system drive.
  8. Now that we've done most of the dirty work (that wasn't so hard, was it?), we need to go smooth out some rough edges. For instance, regreplace only replaces string values - not keys or other random things. So you'll have to do a little manual search-and-replace, but not too much. Also it's good to make sure that we got everything. But first, the next couple steps on WinForums.
    you will see 2 SIDs at the bottom of that key similar to the following...

    \\REGISTRY\\USER\\S-1-5-21-602162358-616249376-839522115-1001"="\\Device\\HarddiskVolume2\\Documents and Settings\\temp\\NTUSER.DAT"

    "\\REGISTRY\\USER\\S-1-5-21-602162358-616249376-839522115-1001_Classes"="\\Device\\HarddiskVolume2\\Document s and Settings\\temp\\Local Settings\\Application Data\\Microsoft\\Windows\\UsrClass.dat"

    See that number after "HarddiskVolume"? It may not be 2, it might be 1 or 3 or 17 (unlikely). Whatever it is, take whatever drive letter you want your directories to be on (D), count how many letters away from the drive it's on now (C), and add it. So if it's 2 right now, and you're moving from C to D, that's 1 away - meaning HarddiskVolume3 would be your new label.
  10. Now copy the folders (except the temp user folder and all users folder) from C:\documents and settings\ to where you want it (D:\Profiles here).
  11. Go ahead and search for "Documents and Settings" and "Program Files", replacing any wrongly-pointing entries to your new location (D:\Profiles, D:\ProgDir) by hand. In a fresh install, there shouldn't be many left.
  12. Do a reboot - a complete reboot is always best when you're working with the registry, I've found. When it comes back up, log in as Adminsitrator.
  13. Try to copy the All Users folder (inside Documents and Settings) over to the D: drive and rename (or delete) the C:\Documents and Settings. If succesful, You're done, otherwise, you may have to wrestle a bit.
  14. If you have problems, you can just try finding and replacing any wrongly pointing entries manually again and rebooting, or try booting into safe mode - whatever you can do to get the settings to stick. In my case, I had my wifi driver running, and I had to go uninstall it (which was a pain), make sure it wasn't trying to boot up with Windows, and finally get rid of the folders on the C:\ drive.

If things went (somewhat) well, you should in the end only have a WINDOWS folder in your C:\ drive, and all your programs and data should be on the D:\ drive (or wherever you chose). New programs should install there by default, and it will be quite better for backup purposes and just a lot cleaner. You may still have some shortcuts and such on your hard drive pointing to your folders that were in the C:\ drive - I used the free ReplaceEm to root out and fix these various pointers.


Post a Comment

Links to this post:

Create a Link

<< Home