I've blogged about Junctions (Reparse Points or "Hard Links") before, as has Travis with his Junction Shell Extension. Junctions are great for organizing your code because you can start using relative paths again, even when your project structure doesn't lend itself to relative paths. (Sometimes folks even SUBST a drive and "everyone builds to S:" to make this easier. I say ick to that.)
It seemed to me as I spread the word about the wonder and glory of Junctions (as was as the fantastic danger as in Windows XP SP2 when you delete a junction from Explorer, you delete what it points to!)
So, I was thrilled to notice some interesting and very cool new things regarding Junctions on Vista.
First, in Vista now, deleting a junction point in Explorer doesn't delete the pointed-too folder. If you've used Junctions in Explorer, you'll realize this is huge.
Also, in Vista, while there's no way from Explorer to tell WHERE a junctions points to, either in the Properties or a Tooltip nor in the "Type" column in Details View (insert obvious feature request here) they at least include a Shortcut Icon Overlay on a Junction. It still says "Folder" when you look at it in Details, while a Shortcut to a Folder says "Shortcut." At least that's a start! In this screenshot the first icon is a folder while the second icon is a junction pointing to the first.
This got me thinking, since I keep all my data on a separate drive D: for "DATA." A lot of us do.
In Vista, "Documents and Setting" is now "C:\Users" and a lot of other stuff has changed. They MOVED my cheese. So, where did they move it, and how do they make things point to the newly moved stuff?
They use Junctions, making their first mainstream appearance! I went to C:\Users and did this:
C:\Users\Scott>dir /a /s | find /i "junction"09/08/2006 01:23 AM <JUNCTION> Application Data [C:\Users\Scott\AppData\Roaming]09/08/2006 01:23 AM <JUNCTION> Cookies [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Cookies]09/08/2006 01:23 AM <JUNCTION> Local Settings [C:\Users\Scott\AppData\Local]09/08/2006 01:23 AM <JUNCTION> My Documents [C:\Users\Scott\Documents]09/08/2006 01:23 AM <JUNCTION> NetHood [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Network Shortcuts]09/08/2006 01:23 AM <JUNCTION> PrintHood [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Printer Shortcuts]09/08/2006 01:23 AM <JUNCTION> Recent [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Recent]09/08/2006 01:23 AM <JUNCTION> SendTo [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\SendTo]09/08/2006 01:23 AM <JUNCTION> Start Menu [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Start Menu]09/08/2006 01:23 AM <JUNCTION> Templates [C:\Users\Scott\AppData\Roaming\Microsoft\Windows\Templates]09/08/2006 01:23 AM <JUNCTION> Application Data [C:\Users\Scott\AppData\Local]09/08/2006 01:23 AM <JUNCTION> History [C:\Users\Scott\AppData\Local\Microsoft\Windows\History]09/08/2006 01:23 AM <JUNCTION> Temporary Internet Files [C:\Users\Scott\AppData\Local\Microsoft\Windows\Temporary Internet Files]Notice that I had to use /a because these junctions are HIDDEN as well. But, because they exist, when folks concatenate things after calling "GetSpecialFolder" they'll still get what they need.
I had a little trouble with my upgrade because I ended up with some stuff on my C: and My Documents on my D:, but Vista was still pointing to C:\Users\Scott for My Documents.
I tried to get tricky like this:
C:\Users\Scott>junction "My Documents" "D:\Scott\My Documents"Junction v1.04 - Windows junction creator and reparse point viewerCopyright (C) 2000-2005 Mark RussinovichSystems Internals - http://www.sysinternals.comC:\Users\Scott\My Documents: JUNCTION Print Name : C:\Users\Scott\Documents Substitute Name: C:\Users\Scott\Documents
But while a cross-drive junction succeeded with Junction.exe, it apparently really didn't:
C:\Users\Scott>dir *doc* /a Volume in drive C is 70 GIGS - SYSTEM Volume Serial Number is 88F3-D225 Directory of C:\Users\Scott09/08/2006 01:23 AM <JUNCTION> My Documents [\??\D:\Scott\My Documents] 0 File(s) 0 bytes 1 Dir(s) 6,877,286,400 bytes free
C:\Users\Scott>dir /a "My Documents" Volume in drive C is 70 GIGS - SYSTEM Volume Serial Number is 88F3-D225 Directory of C:\Users\Scott\My DocumentsFile Not Found
You are supposed to be able to create a "Volume Mount Point" like in *nix where you point a directory at a volume, but that's not exactly what I need here. I'm not sure why it didn't work, because it's supposed to be supported scenario in NTFS.
Well, while I'm not getting the junction to work, I can still move My Documents in the registry by simply right-clicking on the Document folder and moving it with the built-in UI as we've always been able to in Windows XP. It appears that David Mohundro has discovered some of this interesting stuff as well, although I'm not seeing the same behavior as him; my "Documents and Settings" folders are totally gone and emptied, replaced by C:\Users.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.