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
Ltd.

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
    E:\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.
  9. Go to HKLM\SYSTEM\CONTROLSET001\CONTROL\HIVELIST\
    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.

Sunday, July 08, 2007

I'm tired, I think I'm going to go program now.

I was going to write about trying to map Documents and Settings and Program Files to my D:\ drive, but I realized that I'm not in a posting mood, and the last two posts were excruciatingly boring. So, good night. I'm gonna go hack at some code.

Installing Windows (definitely not the energy-efficient kind)

After making sure my data was securely backed up, time for Windows. I was ready to see how a fresh Windows install stacked up with a fresh Linux install, since Windows usually comes preinstalled and perfect. So I popped my Windows XP Pro disc in and booted up. Okay, I admit, I've installed Windows from scratch numerous times before...but for the story's sake, we'll pretend I haven't.

Oh, maybe you want to know what my plan is. I've got an Acer Aspire 1640 with a 120 GB hard drive. Intel integrated video and wireless, anyway, I plan to do an 8GB partition for Windows XP, with the Documents and Settings dir and Program Files on my data partition, which will be 60GB. Both of those will be FAT32/vfat for easy access from Linux. My Linux will be on about an 8GB partition, with whatever's left over being allocated for Linux data. Hopefully I'll have an external hard drive soon for music and pictures and the like, but that's getting ahead of things. Okay, back to your regularly scheduled programming.

So, I boot up, and am presented with...an ugly text-based horror? Eew, what is this, Debian? Hmm, figured that Windows being so user-friendly, it'd have a decent installer like, say, Ubuntu. Oh well, I manage to find the right keys to get a 8GB system partition for my Windows XP, after a few tries to get it FAT (so I can access it nicely from Linux), I hit the "Create Partiton" key and go occupy myself while it does its thing. I come back several minutes later to find my computer rebooting - what? I just created a partition...yargh. Oh well, the graphical installer came up, I suppose I'll create my 60GB data partition when I do my Ubuntu install. So I click through the installer (which annoyingly is stretched on my widescreen), which goes pretty smoothly.

After Windows starts up, I find out that my video card, wireless, and who-knows-what-else don't work right. So this is what it feels like to not have Windows preconfigured for you. Since I didn't want to bother hooking it up to Ethernet, I download it to the desktop and scoot it across with my flash drive. After choking through the 43MB (?!?!?) download, I install my wireless and get down to business.

I go to access my shared folders to burn my backups. First thing, I have to run the glorious Network Setup Wizard if I want to change ANYTHING, and I click through, and realize how much I hate some things. Like the "Disconnected Hardware" box. The second step of the Network Setup Wizard informs you that your network cable is unplugged (well, DUH, I'm using wireless), and INSISTS that I not only look at the list of disconnected harware, but check the box that ensures them that I'm okay with ignoring it. Now the vast majority of laptop users are going to have disconnected hardware, since you generally only use one interface at a time. So what's the point of informing them that their hardware is disconnected - argh, I give up. It just rubbed me way the wrong way. So I set it up right, and found out my files didn't want to copy over correctly. Fine, I'll share my CD drive, I thought. After realizing that I had to have it empty to do so, I went to my desktop to access it, and couldn't. Ugh. Fine, I'll leave this for later. Let's get on with installing Windows.

First thing, I went to getfirefox.com to download Firefox, the first and only time I'll use Internet Explorer. After getting Firefox installed, I navigate to the Acer driver downloads site to get my video drivers. And I find out that they recently made it all-flash. Dang, I hate all-flash sites. After watiting for three years for it to load, I'm mildly pleased by the interface, until I realize that it's not working. I click "Notebooks" in the first box, "Aspire 1640" in the second, all the while muttering about how this could be done with a bit of javascript, and then wait for the list of drivers in the third box to come up. And it does, but...it lists the drivers for EVERYTHING. I have six kajillion video drivers to choose from, none of which are for my laptop. "I HATE YOU!!!" I scream, and my father gives me a strange look. After assuring him that I'm talking to Acer's website, I decided to deal with it later. I just want to get this thing going.

Down the Rabbit Hole: My adventures installing my computer from scratch

So I finally got around to actually redoing my entire computer from scratch. The first step, of course was backup, which I'll cover in this post.

First, I picked up a 2.5" enclosure, which I highly recommend - it makes the process way easier. I had a desktop available with about 20 gigs of free space to play with, so I could just copy my files to that, 7-zip them up, and worry about burning them to DVDs and such later. The enclosure I got was pretty straightforward, I got it for free after rebate from Buy.com, rebates are a hassle, but they're worth it if you're a poor college student like me.

Copying my files was a pretty painless process, but to get at my Linux partitions from Windows, I first tried what I've previously used, ext2 ifs, but it didn't seem to like copying files over. So instead I found Explore2fs, which was very easy to use, worked like a charm, and eventually copied my Linux data to my desktop. I zipped up the home dir (since that's all I wanted) in a few chunks, and deleted the originals. Then I copied my Windows files over (which, annoyingly, didn't have a home dir to work with), and zipped them up in a few DVD-size chunks. After deleting the originals again, I moved all the zips over to my shared directory so that I could burn them (since my desktop didn't have a DVD burner).

Since my files were safe on my desktop, and I didn't want to mess with burning them on my old system, I took my hard drive out of my enclosure and put it back in my laptop. Next up was installing Windows XP.