Sunday, September 23, 2007

User Files Folders and the Desktop.INI

File this story under "Interesting Tidbits". The information I provide below will probably seem rather academic, but it will have important repercussions for things like Folder Redirection which I will be describing later.

If you look back at the picture I attached to my previous article titled "Introducing the User Files Folders!", you will notice that most of Vista's 11 User Files Folders are represented by unique icons (Favorites has a star, while Music has a note, etc.). Most people aren't aware how this trick is done and are surprised when these icons sometimes revert back to a plain, vanilla file folder. Just as in XP, Vista puts a hidden Desktop.INI file in each User Files Folder it creates. Windows Explorer later reads this file to determine how it should label a particular folder and what icon it should associate with it. That's it - that's the whole trick. If a folder eventually reverts back to a plain folder icon, you can bet that it's because the Desktop.INI file got accidentally deleted.

Here is a sample Desktop.INI file from an XP system for the "My Music" folder:

PersonalizedName=My Music

A desktop INI folder can hold a great variety of values and be formatted with different sections, but this simple example will do for our purposes. What I would like to point out is that the Desktop.INI file does specify the icon to display for the folder - it is the IconIndex -237 from the IconFile Shell32.dll.

Did you notice earlier that I mentioned that the Desktop.INI file tells Windows Explorer how it should label the folder? This is important - it's that innocent looking value called PersonalizedName that is assigned "My Music". This may not seem interesting since it appears to hold the value of the folder name - but you can change it. If you change it to some other value like "My MP3s", the user will see this new folder name when browsing the Personal Folder rather than its real name of "My Music" as it is actually stored on the hard disk - the user is fooled into seeing a folder name that doesn't really exist. Lately publications are calling this fake name the Friendly Name.

Do you remember that we are still only talking about XP? Also, please notice that the Desktop.INI folder has an Owner value that has been assigned my login name - this seems unimportant doesn't it.

Time to move on to Vista's Desktop.INI file - here is a sample Desktop.INI file from a Vista system for the "My Music folder:

LocalizedResourceName= @%SystemRoot%\system32\shell32.dll,-21790
Sample Music.lnk=@%SystemRoot%\system32\shell32.dll,-21806

Notice that we still have IconFile and IconIndex and they basically still hold the same values (i.e. -237). The Music folder is still specifying the icon to be displayed in the same way.

But notice that there is no PersonalizedName value. It turns out that LocalizedResourceName serves this function in Vista. At this point I want you to ask "Gord, how can this be? I don't see the value 'Music' listed there?". Great question! You now just see a number like -21790 and the file Shell32.dll. Well, it turns out that if Windows Explorer asks Shell32.dll what -21790 means, it will be told that it means "Music". Vista has added an extra layer of abstraction for the friendly name. I want to leave you wondering why Microsoft might have done this.

Please also notice that the Owner value is no longer listed in Vista's Desktop.INI.

It's now time to reward you for reading this article for this long and surviving the boredom... The experienced LAN admins among you might now be getting worried about your mixed environments. What if you are redirecting the User Files Folders/Personal Folders to a network share and your users might access them from either a Vista box or an XP box. If the Desktop.INI files of each OS use different formats and different values, what will happen to the folders? It turns out everything works out just fine! Here is a test I conducted:

  • I redirected Vista's Music folder to a folder called "Audio" on a network share.
  • I was able to confirm that the Desktop.INI file was doing its job because when I browsed to it with Windows Explorer I still saw the folder as "Music" (there's that trickery again).
  • I then used an XP system to browse to that same folder - what I found was a "My Music" folder - no problem!
But how can this be?? The only possible explanation is that the LocalizedResourceName is even supported by XP but that it just wasn't leveraged before.

The story's not over, but it is enough for today. I've got two more Desktop.INI articles coming before we move onto more interesting topics like Folder Redirection, User Access Control (UAC) and Logon Scripts. If you'd like to learn more about the contents of the Desktop.INI, I've included a link to a wonderful site at the bottom of this page.

No comments: