Redirecting Special Folders

Special folders include the My Documents, My Pictures, and Favorites folders, among many others. Table 4-1 shows the special folders that Windows XP creates after a fresh installation and their default paths. The first column contains each folder's internal name as Windows XP 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 10, "Deploying User Profiles," describes these user profile folders in depth.

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

Users might want to redirect special folders for a variety of reasons, but two come to mind. The first is 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 XP 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 have access to them from anywhere. IT professionals frequently want to redirect My Documents to a network location, too, which makes backing up users' documents easier. This can be done with the IntelliMirror feature Redirected Folders. IT professionals can't use IntelliMirror features without Active Directory, but they can simulate Redirected Folders. Chapter 15, "Working Around IT Problems," shows how to use this hack in that scenario.

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders is the key where Windows XP stores the location of per-user special folders. Each value in this key is a special folder as shown in Table 4-1. These are REG_EXPAND_SZ values, so you can use environment variables in them. Use %USERPROFILE% in a path to direct the folder somewhere inside users' profile folders or %USERNAME% in a path to include users' names. To redirect users' Favorites folders to the network, set the value Favorites, which you looked 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 XP 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 XP 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 where you want to redirect the My Documents folder. (Use environment variables so the script works for all users.) Do the same for the strings FAVORITES, PICTURES, and APPDATA. To configure these settings, right-click Redirect.inf, and then click Install. Chapter 9, "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

start example

 [ 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" 

end example

Note 

The special folders in this section are per-user and exist within users' profile folders. Windows XP 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. Regardless, the same rules apply. Change the location of the folder in User Shell folders; Windows XP automatically updates Shell Folders.



Microsoft Windows XP Registry Guide
Microsoft Windows XP Registry Guide (Bpg-Other)
ISBN: 0735617880
EAN: 2147483647
Year: 2005
Pages: 185

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