I actually just wrote this a few days ago. This may help you out as well.My situation is that I have terminals in all of our scientific labs. At present we have some labs connecting to a MS Terminal server and others connecting to a Citrix MetaFrame server. Some lab personel may have either a PC at thier desk or a Mac (and use the Citrix client).
In the past, order to cut down on log in/out times, I have prevented the Desktop directory from being a part of the profile. (Nothing worse then someone droping a 500MB PowerPoint file on the desktop and they wonder why it takes so long to log in/out.)
code:
; ----------------------------------------------------------------------- ;
; Prevent Certain Folders from Uploading to Central Profile. ;
; ----------------------------------------------------------------------- ;
?
? "Prevent certain folders from uploading to the central profile:"
? " "
IF WRITEVALUE ("Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "ExcludeProfileDirs", "Temporary Internet Files;Desktop;History;Local Settings\Temporary Internet Files;Local Settings\Temp;Local Settings\History;Personal;Start Menu", "REG_SZ") = 0
"Value written to the registry - ExcludeProfileDirs"
ELSE
"Error writing value to the registry - ExcludeProfileDirs"
ENDIF?
? " "
; Policy for Windows 2000 ;
IF WRITEVALUE ("Software\Policies\Microsoft\Windows\System\ExcludeProfileDirs", "ExcludeProfileDirs", "Temporary Internet Files;Desktop;History;Local Settings\Temporary Internet Files;Local Settings\Temp;Local Settings\History;Personal;Start Menu", "REG_SZ") = 0
"Value written to the registry - ExcludeProfileDirs"
ELSE
"Error writing value to the registry - ExcludeProfileDirs"
ENDIF
?
? " "
IF WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\LocalUser\Software\Policies\Microsoft\Windows\System", "ExcludeProfileDirs", "Temporary Internet Files;Desktop;History;Local Settings\Temporary Internet Files;Local Settings\Temp;Local Settings\History;Personal;Start Menu", "REG_SZ") = 0
"Value written to the registry - ExcludeProfileDirs"
ELSE
"Error writing value to the registry - ExcludeProfileDirs"
ENDIF
Hrmm.. after looking at that code, I need to really it clean up. Anyways....
My delema now is that we plan on migrating all the users to the MetaFrame server and then rebuild the MS Terminal server with Citrix and creat a cluster. When clients logged into the the cluster, they could get either of the servers. And have a unique desktop on each server. Having unique desktops on each workstation was accecptable. Unique desktops to each TS was not.
My solution was to create a "TSDesktop" directory on the Home drive of each user that logged into a TS. Change the attributes of that dirctory to Hidden and System. And to move any files that may be located in the Desktop dirctory on the Terminal servers to the new TSDesktop directory. I also wanted the Desktop directory to revert back to the local profile if the user logged onto a workstation.
I'm currently still testing the impact of this code on several users but have yet to have any problems with it.
Quick note: I define the $UserDrive variable at the begining of the script when I use it to map the users Home Directory.
code:
DIM $TSDesktop = "TSDesktop" ; Directory for the Terminal Server Desktop
DIM $UserDrive = "H" ; Mapped drive for the User Directory
? "Creating the " + $TSDesktop + " directory:"
? " "
IF @PRODUCTSUITE = 18
IF DIR ($UserDrive + ":\" + $TSDesktop) = $TSDesktop
"Directory already exists - " + $UserDrive + ":\" + $TSDesktop
ELSE
MD $UserDrive + ":\" + $TSDesktop
IF @ERROR = 0
"Directory has been created successfully - " + $UserDrive + ":\" + $TSDesktop
? " "
SETFILEATTR ($UserDrive + ":\" + $TSDesktop, 6)
COPY "%USERPROFILE%\Desktop\*.*" $UserDrive + ":\" + $TSDesktop
DEL "%USERPROFILE%\Desktop\*.*"
ELSE
"Error creating directory - " + $UserDrive + ":\" + $TSDesktop
ENDIF
ENDIF
WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", $UserDrive + ":\" + $TSDesktop, "REG_EXPAND_SZ")
ELSE
WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", "%USERPROFILE%\Desktop", "REG_EXPAND_SZ")
ENDIF