Redirecting Special Folders


Redirecting Special Folders

The My Documents, My Pictures, and Favorites folders, among many others, are examples of special folders. Table 4-1 shows the special folders–and their default paths–that Windows creates when creating a new profile. The first column contains each folder's internal name as Windows and other programs know it. The second column contains each folder's default path, which almost always starts with %UserProfile%, making these folders part of each user's profile folder. Chapter 12, “Deploying User Profiles,” describes user profile folders in depth.

Users might want to redirect special folders for a variety of reasons, but in two scenarios in particular. The first is when you want to redirect the My Documents folder to a different volume. For example, users might redirect My Documents to drive D so they can reinstall Windows on drive C without losing their documents. The second scenario is when users have a network and want to access their documents from more than one computer. In that case, they can redirect both their My Documents and Favorites folders to a network location so they can access them from anywhere. IT professionals also frequently want to redirect My Documents to a network location, which makes backing up users' documents easier. This can be done with the IntelliMirror feature Folder Redirection. IT professionals can't use IntelliMirror features without Active Directory, but they can simulate Folder Redirection. Chapter 18, “Fixing Common IT Problems,” shows how to simulate Folder Redirection in that scenario.

Microsoft does not recommend that you use the techniques described in this section in a business-computing environment, particularly if that environment includes Active Directory and Group Policy. (Group Policy provides policies for redirecting folders.) In environments that don't include Active Directory, these techniques remain valuable; however, you must test them in a lab environment before deploying them in a production environment.

Table 4-1 Special Folders

Name

Default Path

AppData

%UserProfile%\Application Data

Cache

%UserProfile%\Local Settings\Temporary Internet Files

Cookies

%UserProfile%\Cookies

Desktop

%UserProfile%\Desktop

Favorites

%UserProfile%\Favorites

History

%UserProfile%\Local Settings\History

Local AppData

%UserProfile%\Local Settings\Application Data

Local Settings

%UserProfile%\Local Settings

My Pictures

%UserProfile%\My Documents\My Pictures

NetHood

%UserProfile%\NetHood

Personal

%UserProfile%\My Documents

PrintHood

%UserProfile%\PrintHood

Programs

%UserProfile%\Start Menu\Programs

Recent

%UserProfile%\Recent

SendTo

%UserProfile%\SendTo

Start Menu

%UserProfile%\Start Menu

Startup

%UserProfile%\Start Menu\Programs\Startup

Templates

%UserProfile%\Templates

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders. Each value in this key is a special folder, as shown in Table 4-1. Because these are REG_EXPAND_SZ values, you can use environment variables in them. Use %UserProfile% in a path to direct the folder to a location inside users' profile folders, or use %UserName% in a path to include users' names. To redirect users' Favorites folders to the network, set the value Favorites, which you can look up in Table 4-1, to \\Server\ Share\%UserName%\Favorites, where \\Server\Share is the server and share containing the folders. The next time the user logs on, Windows updates a second key, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, with the paths from User Shell Folders, so you don't have to update it. In fact, Microsoft's documentation says Windows doesn't use Shell Folders.

The following listing shows you how to redirect special folders automatically. Save this listing to the text file Redirect.inf and replace the string PERSONAL with the location to which you want to redirect the My Documents folder. (Use environment variables so the script works for all users.) Perform the same steps for the strings FAVORITES, PICTURES, and APPDATA. To configure these settings, right-click Redirect.inf, and then click Install. Chapter 11, “Scripting Registry Changes,” shows you other ways to deploy these settings. You can uninstall this script using Add Or Remove Programs.

Listing 4-1 Redirect.inf

[Version]  Signature=$CHICAGO$    [DefaultInstall]  AddReg=Reg.Settings  AddReg=Reg.Uninstall  CopyFiles=Inf.Copy    [DefaultUninstall]  DelReg=Reg.Settings  DelReg=Reg.Uninstall  DelFiles=Inf.Copy    [Reg.Settings]  HKCU,Software\Microsoft\Windows\CurrentVersion\Explorer\  \User Shell Folders,AppData,0x20000,"%APPDATA%"  HKCU,Software\Microsoft\Windows\CurrentVersion\Explorer\  \User Shell Folders,Personal,0x20000,"%PERSONAL%"  HKCU,Software\Microsoft\Windows\CurrentVersion\Explorer\  \User Shell Folders,My Pictures,0x20000,"%PICTURES%"  HKCU,Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell \  Folders,favorites,0x20000,"%FAVORITES%"    [Reg.Uninstall]  HKCU,Software\Microsoft\Windows\CurrentVersion\Uninstall\%NAME%  HKCU,Software\Microsoft\Windows\CurrentVersion\Uninstall\  \%NAME%,DisplayName,,"%NAME%"  HKCU,Software\Microsoft\Windows\CurrentVersion\Uninstall\%NAME%,UninstallString\  ,,"Rundll32.exe setupapi.dll,InstallHinfSection DefaultUninstall 132"\  " %53%\Application Data\Custom\Redirect.inf"    [Inf.Copy]  Redirect.inf    [DestinationDirs]  Inf.Copy=53,Application Data\Custom    [SourceDisksNames]  55=%DISKNAME%    [SourceDisksFiles]  Redirect.inf=55    [Strings]  NAME       = "Jerry's Redirect Folders"  APPDATA    = "\\Server\Folders\%UserName%\Application Data"  PERSONAL   = "\\Server\Folders\%UserName%\My Documents"  PICTURES   = "\\Server\Folders\%UserName%\My Documents\My Pictures"  FAVORITES  = "\\Server\Folders\%UserName%\Favorites"  DISKNAME   = "Setup Files"

NOTE
The special folders in this section are per-user and exist within users' profile folders. Windows also lists per-computer special folders in HKLM. Examples of per-computer folders include Common AppData, Common Desktop, and Common Documents. It's not as useful to customize per-computer folders; however, the same rules apply. Change the location of the folder in User Shell Folders; Windows automatically updates Shell Folders.



Microsoft Windows Registry Guide
Microsoft Windows Registry Guide, Second Edition
ISBN: 0735622183
EAN: 2147483647
Year: 2003
Pages: 186

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net