UPHClean Provides Faster Logoffs For All
Microsoft has quietly released the User Profile Hive Cleanup service.
March 26, 2006
Once in a while, a particular Windows feature will irritate me to the point at which I'll just give up and just stop using it. I hate to admit defeat, but I've only got so much time. But then, occasionally, Microsoft will release a useful fix for one of those annoying features. For example, in Windows NT 3.1, setting up the client side of home directories was infuriating, requiring a ton of work, and after a while I just didn't bother setting up home directories for some users. But, seven years after the initial pain, Windows 2000 fixed home directories, and now I use them all the time.
Another annoyance—roaming profiles that don't get updated on logoff—has been around since, if memory serves, 1993. Here's how the problem manifests itself: When you try to log off, you see a Saving Settings message on your screen for an eternity, and finally you get a dialog box that tells you the system wasn't able to "release a handle to your profile" or "unload a user hive." (The dialog box's text varies from NT 3.1 to Windows Server 2003.) The first result is that your roaming profile doesn't get updated on its server, and—so that you can update your profile—you get to perform the happy task of removing one program or service after another on your workstation until you find the one that's causing the problem. The second result is that after you've gone through this scenario a few times, you give up on roaming profiles. And that's a shame, because if managed correctly, roaming profiles are wonderful.
I have good news for you: Microsoft has quietly released a service that solves the problem, and you can install it on your NT 4.0 or later workstation. (You can also install it on your server, if you're in the habit of using a roaming profile account to log on to servers.) The service is called User Profile Hive Cleanup, and you can find it at the Microsoft Download Center. Search for "UPHClean" to find download links for the service's readme.txt file, as well as the program itself, UPHClean-setup.msi. The program link kicks off an installation wizard, asking you to accept a software license and choose an installation location, and UPHClean is installed with the program name uphclean.exe—good to know should you ever have to stop or start the service from the command line. Typing
net stop uphclean
is much easier than typing
net stop "user profile hive cleanup"
What will you see when the service runs? Hopefully, you'll see nothing. The user hive is simply the collection of user-specific settings in the HKEY_CURRENT_USER registry key. All that data is saved in a file called ntuser.dat, which you might have noticed in your profile. This file is otherwise known as the user hive file. As you work on your system, your computer looks for its registry settings not in ntuser.dat but instead in an image of ntuser.dat that's been copied into your system's RAM.
Programs that must read parts of your registry do so by asking the OS for a "handle" (in programmer parlance). As long as a section of the registry has a handle "connected" to it—or, more correctly, "has a handle open on it"—that part of the registry is considered to be in flux, and the OS doesn't want to write that data out until it's settled down. As you work on your computer, many applications have open handles to your registry. But when you close an app, any handles it has left open are summarily closed. A normal logoff, then, waits for all of your apps to close, releasing their handles on the registry. After there are no more open handles in HKEY_CURRENT_USER, it's okay for the logoff code to write the current data in the hive to ntuser.dat, and then you're logged of. But sometimes handles stay open, and so the logoff process waits, and waits, and waits—and so do you. Eventually the logoff process gives up (e.g., "times out") and just skips writing out ntuser.dat. In such situations, you might lose settings, and—most noticeably—you had to waste a few minutes of your life waiting for a computer.
So, how do situations occur in which all your apps are closed but handles remain open? Because some badly written apps—almost always services, which run all the time and don't stop when you log off—open handles on your user hive. The apps shouldn't do that, but—again—it can happen with bad coding.
UPHClean has a simple answer for that. As your system tries to log off, UPHClean looks for handles to your user hive that are held by services. It then remaps those handles from locations in your user hive to the user hive for a user called Default User, which is the user who is logged on when no one is logged on. Your registry is freed, ntuser.dat gets written, and you're quickly logged off.
That's a neat trick, and it's just the start. UPHClean will create a list of offending applications for you so that you can chastise their creators. You can also create lists of apps not to remap. So if your logoffs are a bit slow, give UPHClean a try!
(As I write this, I can see one fly in the ointment. Unfortunately, the User Profile Hive Cleanup service works only on 32-bit versions of Windows. A 64-bit version might appear eventually, perhaps in early summer.)
About the Author
You May Also Like