- Saturday, March 24, 2007
Emulating Vista's User Directory Structure on XP
Perhaps the best new "feature" of Windows Vista is the Unix-inspired re-organization of user home directories. That is, instead of placing user-specific files under the abhorrent
Documents and Settingsdirectory, each user's folder resides under the command-line-friendlyUsersdirectory in the root system drive. Even better, your music is no longer considered a document. It's hard to argue against the fact thatC:\Users\Derek\Musicis cleaner thanC:\Documents and Settings\Derek\My Documents\My Music(or in some cases, the 8.3 friendlyC:\DOCUME~1\Derek\MYDOCU~1\MYMUSI~1, ack!).I use Vista on a couple of my computers, and I've grown to appreciate the new folder structure. Gone are the days of hacking together your own home directory structures just to try and cope with the unfriendly madness (who hasn't created a folder or two under
C:\just to make them typable?). Unfortunately, I still use several machines running XP, so it's hard to rely on this sane structure -- leading to grotesque hacks such as functions calledghetto-dosifyin my.emacsfile (I wish I were kidding).There are some additional advantages to utilizing the built-in home directory structure rather than creating your own. For example, the Run dialog resolves path reference relative to your home directory. So, if you type
Start -> Run -> ., your home directory will open. Sub-folders can be accessed just as easily -- typingStart -> Run -> dev\blogopens my blog source tree. Also, many tools (backup, indexing, etc.) will only consider content in your actual profile directory (the one that Windows knows about).Another nice benefit is that the compact path structure is Cygwin-friendly, so you can safely set your
HOMEenvironment variable (also used by Emacs, of course). Thus,~/Desktopin Cygwin matches~\Desktopin Powershell. I keep myHOMEdirectory synced across many machines (Vista, XP, and Linux) using Subversion, and it's nice being able to keep everything in the same place.Fortunately, we can make some relatively simple tweaks to our XP systems to make the structure more closely resemble that of our Vista and Unix friends.
Junction, Junction, What's your Function?
Chances are you've been running your operating system for a while, and you've got a bunch of clutter under your
Documents and Settingsfolder. More importantly, you probably have a bunch of applications with stored absolute paths under that folder, not to mention all of those common dialog pointers. So obviously, just renaming theDocuments and Settingsfolder is going to cause more problems than it'll solve.If XP had symlinks (another feature added in Vista), of course, we'd have an easy solution. We could simply type
ln -s DOCUME~1 Users, and we'd be off to a good start. We could update environment variables to use our new path structure, and we wouldn't break the old path references. Fortunately, XP does support directory symlinks ... well, sort of. XP's default file system, NTFS, supports something called a "junction point". For our needs, it'll do.While junctions are supported by NTFS, there is no built-in tool for creating them. Enter Junction, a simple command line tool for creating (and viewing targets of) NTFS junction points. With the tool located in your PATH, run the following command sequence to create the link:
C:\Documents and Settings\Derek>cd \ C:\>junction Users "Documents and Settings" Junction v1.04 - Windows junction creator and reparse point viewer Copyright (C) 2000-2005 Mark Russinovich Systems Internals - http://www.sysinternals.com Created: C:\Users Targetted at: C:\Documents and Settings
Special Folders
At this point, we can access our home directory under the
Userspath, but unfortunately Windows has no idea that we've actually intended to change our home directory. For example, starting a fresh command line session stills shows that old, annoyingDocuments and Settingspath.To fix this, we need to dig into the registry. Under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList, there should be a number of keys in the formS-x-x-xx-.... Browse through the keys until you find the one with aProfileImagePathvalue ending with your user name (e.g.%SystemDrive%\Documents and Settings\Derek). Change this value to use the new path (e.g.%SystemDrive%\Users\Derek). You will need to restart Windows for it to pick up the change.
After rebooting, you should default to the new
Userspath when starting a fresh console session. And because it's actually a junction point, all of your existing files should be right there with you. This is a nice start, but there are still some annoyances:My Documentsshould beDocuments,My Music(and its similarly named friends) should also drop the silly "My" prefix, and ascend one directory (unless you think music is a document, of course).Again, junction points are exactly what we need. Use the following command sequence to set them up:
C:\Users\Derek>junction Documents "My Documents" ... C:\Users\Derek>for %f in (Music Pictures Videos) do junction %f "My Documents\My %f" ...
You might also want to hide the
My Documentsfolder, so you don't see two references to the same folder when browsing your home directory. You could just make it hidden, but if you're like me you have hidden folder display enabled. In this case, we just need to make it hidden and give it the system attribute using the following command:attrib +S +H "My Documents".Our paths are now much prettier, but we do get stuck with the ugly default folder icon. Fortunately, you can right click on the folder whose icon you wish to update, click Properties, and change the icon in the Customize tab (you must do this before the next step, where they are assigned as special folders). I use the normal icons in
shell32.dllforDocumentsand the like. For my root home directory (Derek), I useuser-home.ico(attached to this post) from the Tango Desktop Project. The icon was conveniently translated to ICO format by Ben Brown. You might receive a warning about "enabling task folders", this is safe to ignore.As with the
Usersjunction point, we need to tell Windows about our new paths. For this, we'll use a Microsoft tool called Tweak UI. Install the tool, start it (Start -> Run -> tweakui), and select theSpecial Foldersitem underMy Computerin the tree control. Here you can select each path for which we created a junction, and assign the new path.
Common Dialogs
We've solved our ugly path problem, but overall usability still leaves something to be desired. For example, our common dialogs all have direct pointers to our
Documentsfolder, but it's still rather painful to get to our root home directory to, say, open a music file.Fortunately, Tweak UI comes in handy here as well. Under
Common Dialogs, selectPlaces Bar, and chooseCustom Places Bar. Here, you can define up to five paths that you will have easy access to using the common file dialog used by most Windows applications.
Here's the new dialog in action:

Another nice convenience is having a home directory link in your start menu, as below (simply drag the link there to create the shortcut):

Attachments
Comments
- Sunday, March 25, 2007 4:17:27 AM by CoreyThanks for this--helps out neat freaks like myself!
- Monday, April 02, 2007 2:55:40 PM by tom tI'm using Emacs on Vista. Vista won't let emacs write to c:/, where .emacs , .emacs-places, are kept. Suggestions? Give Full Control to C:/ to my user? Would rather make Emacs use some other place for these files but don't see how to do it.
- Tuesday, April 03, 2007 3:21:43 AM by tom tEmacs/Vista problem solved--I defined an environment variable HOME = /users/tom and emacs uses that location now for .emacs-places, .emacs, etc.
- Thursday, April 05, 2007 6:17:02 AM by oliverwhat i did on my was completely rerouted my home folder in another partition and edited the shell folders and user shell folders inthe hives of the registry via regedit. but this is a cool way to do. i'll practice onthe other machine :)
- Saturday, April 07, 2007 8:52:36 PM by Josh MYours was the first article to come up when I did a search on changing the location of a Vista user profile directory. So, I thought I'd add that I wrote up a quick HOWTO on how I did this.
http://joshmouch.wordpress.com/2007/04/07/change-user-profile-folder-location-in-vista/ - Thursday, April 19, 2007 6:12:33 AM by NathanVery cool, I didn't know that vista added symlinks. That must have been why it took so long ;) Only downfall with this method is that some apps don't use the RegKey, they just hardcode the path in their programs :(. Thanks though. BTW is the question below a robot detector?
- Tuesday, June 26, 2007 5:22:40 AM by AnthonyThanks a lot, I've been waiting for something like this for a while.
- Monday, August 06, 2007 5:14:13 AM by FortisThanks! Finally you helped me to make the directory structure I like. And the new 'home' icon looks cool however it does not show up on the 'start' menu...
- Monday, December 03, 2007 7:03:22 AM by DanielaHelpfull.. Thanks a lot!
- Thursday, December 27, 2007 9:44:48 PM by SteveThis is great, thank you! However, when I open windows explorer "My Documents" is still listed at top, which goes to the documents folder in my home directory. Is there a way to have it go just to the home directory?
- Sunday, January 20, 2008 3:21:49 AM by Ryan MeraySo from what I can tell, the junction function is useless in situations where you have two drives, say a 750GB primary drive and a 150GB boot drive, and you want the 750GB drive to become the holder of your Users folder instead of the smaller drive.
I was hoping that Junction would allow previous applications to continue to run off the data located in the old destination, while the new stuff created after the registry edits would actually physically be stored at the junctioned location. Instead, it looks like that Junction location is merely a permalink to the old location, which leaves the data on the smaller boot drive.
Looks like I'm gonna have to dig through my book of registry edits to get that permanant move. Bummer.
This is pretty slick though for single-drive installations. - Saturday, January 26, 2008 7:08:30 PM by MortenCool! I completely agree with you on that being the best "feature" of Windows Vista.
Thanks for giving me the best of Vista on XP :D
One other thing, how did you make Windows XP look like that? I really like the dark-blueish look. - Wednesday, June 25, 2008 2:27:55 AM by ChrisHello, Ryan Meray, there is indeed a way to do it using separate hard drives. If you move the "My Documents" folder from your c: drive to your external drive, and then create the junction back to the C: drive, then it will work as you wish!
- Sunday, August 31, 2008 4:00:36 PM by KorvThank you very much! This works great! I had to fix some stuff like my pictures etc. disappearing from start menu, but now its working perfectly. I've been looking for something like this for a long time!
- Tuesday, September 30, 2008 2:55:30 AM by LouGreat writeup thanks for sharing. btw what theme is that you are using? I like the color scheme.
- Thursday, October 23, 2008 3:39:15 AM by BradAwesome work. This was pretty much the only feature I liked about Vista. I have a couple questions though:
1. When I click on my new "Documents" folder, I still see "My Music...etc". How do I get rid of (hide) these without deleting everything.
2. When I display hidden folders and I navigate to "C:/Users/Brad" everything is displayed including "Application Data" and all that stuff. Is there anyway to keep all that from displaying there and have it only display in the existing "documents and settings" folder? - Saturday, November 29, 2008 2:46:08 PM by MikeWhat theme are you using in the screen shots above for XP?
thanks, Mike - Saturday, February 07, 2009 2:22:05 PM by Wolfgang SchneiderHi,
this sounds like what I am looking for ... but I am unclear whether I have to first create the new folders to which I will then "junction" the old folders? Do I need to create the folders on drive D:, then copy contents and folders from c:\documents and Settings\wolfgang\... and afterwards I can then create the "junction" to D:\users etc ?
Any clarification would be appreciated.
Cheers,
Wolfgang
eMail: wschn123@t-online.de - Saturday, July 04, 2009 5:12:01 AM by Chris PThis is a great post - I've set up a real Home directory now. One thing I also did was made a "My Home" Virtual Folder using information from:
http://msdn.microsoft.com/en-us/library/ms997573.aspx
My registry file to amke this work is here:
===
Windows Registry Editor Version 5.00
; These reg entries create a "Virtual Folder", ie. a new folder visible in the shell
; that looks and behaves like a users "home" directory.
; See: "Creating Shell Extensions with Shell Instance Objects":
; http://msdn.microsoft.com/en-us/library/ms997573.aspx
; NOTE this my UUID (AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D) - I guess you should make your own?
[HKEY_CLASSES_ROOT\CLSID\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}]
@="Home"
"InfoTip"="Home Directory"
; This is: "%SystemRoot%\system32\ieframe.dll,0"
; NOTE the ",n" is the difference between the IconID you want and the IconID of the first Icon in the file
[HKEY_CLASSES_ROOT\CLSID\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,65,00,\
66,00,72,00,61,00,6d,00,65,00,2e,00,64,00,6c,00,6c,00,2c,00,30,00,00,00
; This is: %SystemRoot%\system32\shdocvw.dll - the DLL that makes "Shell Instance Objects" work
[HKEY_CLASSES_ROOT\CLSID\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}\InProcServer32]
"ThreadingModel"="Apartment"
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
64,00,6f,00,63,00,76,00,77,00,2e,00,64,00,6c,00,6c,00,00,00
; This is a "special" uuid that means "CLSID_FolderShortcut"
[HKEY_CLASSES_ROOT\CLSID\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}\Instance]
@=""
"CLSID"="{0AFACED1-E828-11D1-9187-B532F1E9575D}"
; This means: CSIDL_PROFILE - or the user home directory special folder
[HKEY_CLASSES_ROOT\CLSID\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}\Instance\InitPropertyBag]
"TargetSpecialFolder"="0x0028"
; The ShellFolder attributes are:
; SFGAO_CANRENAME (0x00000010)
; SFGAO_DROPTARGET (0x00000100)
; SFGAO_FOLDER (0x20000000)
; SFGAO_FILESYSTEM (0x40000000)
; SFGAO_HASSUBFOLDER (0x80000000)
[HKEY_CLASSES_ROOT\CLSID\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}\ShellFolder]
"Attributes"=dword:e0000110
"WantsFORPARSING"=""
; The uuid that is the CLSID also needs to be added to the shell folder namespace, in this case under the "Desktop" folder.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{AE5CCCC6-31F7-48C2-9028-7ABF7EF8FE9D}]
@="Home Directory"
===