2. What's What and
Where in a User Profile
A user profile contains all the settings and files for a user's work
environment. In addition to personal documents and media files, this
profile includes the user's own registry settings, cookies, Internet Explorer
Favorites, and user data and settings for installed programs.
By default, each user who
logs on to a computer has a local user profile, which is created when
the user logs on for the first time. Local user profiles are stored in %SystemDrive%\
Users. Each user's profile is stored in a subfolder where the user
account name is the folder name (for example, C:\Users\Katy). The entire
path for the current user's profile is accessible via another commonly
used environment variable, %UserProfile%.
To open your user profile,
click Start and then click your user name at the top of the right
column. Using the default Windows Explorer view settings, what you see
will look much like Figure 5. For a new user profile, Windows
creates 11 subfolders, each intended to hold a different category of
personal information.
In Windows XP, the
default data location for each user profile was the My Documents folder,
with My Pictures and My Music created as subfolders in that location.
Windows Vista introduced the concept of a user profile with separate
subfolders for different data types and removed the "My" prefix from
these locations. With Windows 7, the personal pronoun is back. Or is it?
If you open a Command Prompt window and look at a raw directory listing
of your user profile, you'll see that the actual name of the folder
displayed as My Documents is simply Documents. The same is true for the
Music, Pictures, and Videos folders. So where does the "My" come from?
The display text comes from a custom Desktop.ini file that appears in
each of these four folders. An entry at the top of the file points to a
location within the system file Shell32.dll, which contains a localized
name for this folder that varies according to your language. If you want
to get rid of the pronoun, open your user profile folder, right-click
the folder (My Documents, My Music, and so forth), and click Rename.
Whatever text you enter here becomes the new value in the
LocalizedResourceName value line in Desktop.ini.
|
In addition to these
visible document folders, a user profile includes a number of hidden
registry files, a hidden AppData folder, and several junctions provided
for compatibility with Windows XP. In the remainder of this section, we
break out some of the more interesting folders and subfolders within
this location.
2.1. Default
User Data Folders
The 11 visible data
folders are as follows:
Contacts This folder first
appeared in Windows Vista and was designed to store contact information
used by Windows Mail. It is not used by any programs included in Windows
7 and is maintained for compatibility purposes
with third-party personal information management programs.
Desktop This folder contains items that appear on the user's desktop,
including files and shortcuts. (A Public counterpart also contributes
items to the desktop.) A link to this location appears by default in the
Favorites section of the navigation pane.
Downloads This folder, which was introduced in Windows
Vista and has no predecessor in Windows XP, is the default location for
storing items downloaded from websites. A link to this location appears
by default in the Favorites section of the navigation pane.
Favorites This folder contains Internet Explorer
favorites. To open it quickly in Windows Explorer, use the shortcut shell:favorites.
Links This folder
contains shortcuts that appear under the Favorites heading in the
navigation pane. You can create shortcuts here directly, but it's easier
to drag items from a file list or the address bar directly into the
navigation pane.
My Documents This folder is the default location for
storing user documents in most applications.
My Music This folder is the
default location for ripped CD tracks. Most third-party music programs
store downloaded tracks in a subfolder here.
My pictures This folder is the
default storage location for programs that transfer images from
external devices (such as digital cameras).
My Videos This folder is the
default location for programs that transfer video data from external
devices.
Saved
Games
This folder is the default storage location for game programs that can
save a game in progress. All games included in the Windows 7 Games
Explorer use this folder.
Searches This folder stores saved search specifications,
allowing you to reuse previous searches.
2.2.
Application Data
The hidden AppData folder,
introduced in Windows Vista, is used extensively by programs as a way to
store user data and settings in a place where they'll be protected from
accidental change or deletion. This folder (which performs the same
function as the Application Data folder in Windows XP) contains
application-specific data—customized dictionaries and templates for a
word processor, junk sender lists for an e-mail client, custom toolbar
settings, and so on. It's organized into three subfolders,
named Local, LocalLow, and Roaming. The Roaming folder (which is also accessible via
the environment variable %AppData%) is for data that is made available
to a roaming profile (a profile stored on
a network server; the server makes the profile available to any network
computer where the user logs on). The Local folder (which is also accessible via the
system variable %LocalAppData%) is for data that should not roam. The LocalLow
folder is used only for Internet Explorer Protected Mode data.
Subfolders under
AppData\Local include the following:
Microsoft\Windows\History This hidden folder
contains the user's Internet Explorer browsing history. You can open it
directly using the shortcut shell:history.
Temp This folder
contains temporary files created by applications. The %Temp% variable
points to AppData\Local\Temp.
Microsoft\Windows\temporary
Internet Files This hidden folder contains the offline cache for Internet
Explorer as well as attachments saved from Microsoft Outlook messages.
Use shell:cache
to open it in Windows Explorer.
Subfolders under
AppData\Roaming\Microsoft\Windows include the following:
Cookies This hidden
folder contains Internet Explorer cookies and can be accessed directly
using the shortcut shell:cookies.
Libraries You'll find XML
files that define the contents of default and custom libraries here.
Network Shortcuts This folder contains shortcuts to network shares that appear in
the Computer folder. The folder is not hidden; you can add your own
shortcuts here, although it is easier to right-click in Computer and
choose Add A Network Location.
Recent Items Shortcuts to recently used documents
are automatically saved here; if you customize the Start menu to include
a Recent Items link, the most recent 15 shortcuts appear on that list.
SendTo This folder
contains shortcuts to the folders and applications that appear on the
Send To submenu. Send To is a command that appears on the shortcut menu
when you right-click a file or folder in Windows Explorer (or on the desktop). The SendTo folder is not
hidden. You can add your own items to the SendTo menu by creating
shortcuts here. Use shell:sendto to open this folder
and add or delete shortcuts.
Start Menu This folder contains items that appear on the
Start menu. (The Start menu also includes items stored in a Public
counterpart to this folder, %ProgramData%\Microsoft\Windows\Start
Menu\Programs\Startup.)
Templates This folder contains shortcuts to document
templates. These templates are typically used by the New command in
Windows Explorer (on the shortcut menu) and are referenced by the
FileName value in the HKCR\class\ShellNew
key, where class
refers to the extension and file type.
Normally, the Send To menu displays a limited
selection of items,
including the Desktop and your Documents library as well as any
removable storage devices and mapped network drives. To see an expanded
Send To menu that includes all folders in your user profile, hold down
Shift and then choose Send To from the right-click shortcut menu.
|
2.3.
Junctions Used for Compatibility with Windows XP
Most applications that
write to locations within the user profile query the operating system
as needed, rather than writing to absolute addresses. A well-behaved program that
was originally written for Windows XP will thus have no trouble
accommodating the changed names and locations of profile folders in
Windows Vista and Windows 7. On the other hand, a program that looks for
Documents And Settings (the root of profile folders in Windows XP) as
an absolute address could encounter problems when it tries to open or
save files.
The solution? Beginning
with Windows Vista, each user profile contains junctions
(reparse points) that redirect Windows XP folder names to the appropriate names as used in
Windows Vista and Windows 7.
You can see how these
junctions are set up by running a Command Prompt session and typing cd %userprofile% and then dir /ads (the /ads switch restricts output to directories that
also have the system attribute). The output from this command will look
something like Figure 6.
The reparse points
in this directory list are identified by the label <JUNCTION>.
The fourth column in the display lists the Windows XP folder name
(SendTo, for example) followed, in brackets, by the redirect address
(C:\Users\edbott\AppData\Roaming\Microsoft\Windows\ SendTo). If you
display the same folder (%UserProfile%) in Windows Explorer, with hidden
and system files visible, the junctions will look like shortcuts and
won't include any information about their targets.
If you set
Windows Explorer to show hidden files and folders and then double-click
any of the junctions that map to locations in the Users folder (or the
Documents And Settings junction that maps to the Users folder itself),
you'll be rebuffed with an error message like this one:
That's because in all of
these junctions,
the Everyone group has a Deny access control entry (ACE) preventing
users from listing folder contents. This Deny ACE might seem drastic,
but it's Windows' way of telling you to keep your hands off the
compatibility infrastructure.
In every case, there's a
proper path to the folder you're really looking for; you just need to
unlearn the Windows XP structure.
The Deny ACE does not
prevent you from deleting a junction, but you should never perform such a
deletion unless you absolutely know what you are doing. Although a
junction looks like an ordinary shortcut in Windows Explorer, it's not
what it appears to be. Deleting a shortcut deletes a pointer, leaving
the pointee unchanged. Deleting a junction has the same effect as
deleting the location to which it points. Trust us: you don't want to
discover this the hard way
|
Table 1 lists the junction points created
by default in the Users folder.
Table 1. Junction
points in the Windows 7 Users Folder
Junction Name | Target in Windows 7 File System |
---|
Application Data | %UserProfile%\AppData\Roaming |
Cookies | %UserProfile%\AppData\Roaming\Microsoft\Windows\Cookies |
Local Settings | %UserProfile%\AppData\Local |
My Documents | %UserProfile%\Documents |
NetHood | %UserProfile%\
AppData\Roaming\Microsoft\Windows\Network Shortcuts |
PrintHood | %UserProfile%\AppData\Roaming\Microsoft\Windows\Printer
Shortcuts |
Recent | %UserProfile%\AppData\Roaming\Microsoft\Windows\Recent |
SendTo | %UserProfile%\AppData\Roaming\Microsoft\Windows\SendTo |
Start Menu | %UserProfile%\
AppData\Roaming\Microsoft\Windows\Start Menu |
Templates | %UserProfile%\AppData\Roaming\Microsoft\Windows\Templates |
2.4. The
VirtualStore Folder
Many legacy applications
write data (such as configuration information) to areas that are
ordinarily inaccessible to standard accounts. This behavior presented
few problems in Windows XP because most users ran with administrative
privileges. In Windows 7 (as in Windows Vista), the User Account Control
(UAC) feature means that all users, even those with administrator
accounts, run with a standard user token in ordinary operation. To
prevent compatibility problems, UAC redirects problematic file and
registry writes (and subsequent reads) to per-user virtualized
locations.
Note:
If you disable UAC, file and registry virtualization are
disabled as well. If you log on using an account in the Administrators
group with UAC disabled, any program you run can write directly to
locations in the file system and the registry that would otherwise be
protected by UAC.
So, for example,
if an application, running in your security context, attempts to write
to a location within %ProgramFiles%, the write will be redirected to a
comparable location within %LocalAppData%\VirtualStore. When the application subsequently
reads what it has written, the read request is redirected to the same
virtualized location. As far as the application is concerned, everything
is perfectly normal, and the operating system has prevented
standard-user access to the %ProgramFiles% folder.
If you open a
folder in which a virtualized write has occurred, a Compatibility Files
link will appear on the Windows Explorer toolbar, as in this example
from a program that insisted on writing a configuration file to the
Windows folder:
Clicking
Compatibility Files will take you to the VirtualStore location where the data is actually
written.
A similar form
of virtualization protects sensitive areas of the registry. Programmatic
access to HKLM\Software is redirected to
HKLM\Software\Classes\VirtualStore.
Note the following about virtualization:
Virtualization
does not affect administrative access to files or registry keys.
Virtualization does not affect 64-bit processes.
Virtualized data does not move
with roaming profiles.
Virtualization is provided for the sake of compatibility
with current legacy programs; Microsoft does not promise to include it
with future versions of Windows.
3. Common
Profiles
Windows creates a
local user profile
for each user account, storing the profiles in subfolders of
%SystemDrive%\Users with folder names that match the account names. In
addition to these user profiles, the operating system creates two
others:
public The Public profile
contains a group of folders that mirror those in your user profile. You
can see the Public Documents, Public Music, Public Pictures, and Public
Videos folders in their matching libraries. The advantage of these
folders is that other users can save files to these locations from
different user accounts on the same computer or from across the network.
The Windows XP equivalent of the Public profile is called All Users,
and this profile also serves to store application data designed to be
available to all users. In Windows 7 and Windows Vista, this "all users"
application data is stored in %SystemDrive%\ProgramData (which has its
own system variable, %ProgramData%).
Default When a user logs on to a computer for the first time
(and her account is not set up to use a roaming profile or mandatory
profile), Windows creates a new local profile by copying the contents of
the Default profile to a new folder and giving it the user's name.
Therefore, you can configure the Default profile the way you want new
users' initial view of Windows to appear. Note that the Default folder
is hidden, and you must approve a UAC consent dialog box to add files to
it.
If you enable the Guest account, it gets its own profile in the
Users folder as well.
Warning:
In
the unlikely event that Windows is unable to access your user profile
when you log on, the system might create a temporary user profile in
%SystemDrive%\Users\Temp, I warning you at logon that it has done so.
Any changes you make to this temporary profile (including any files you
save in its data folders) will be deleted when you log off.