S
SteveV
We have approximately 100 users setup to use AD roaming profiles and
offline files. Users can login to any of 50 or so desktops and have
access to their document, desktop setting, etc regardless of which
machine they log in to.
This works very well for our environment but after several months the
desktop machines start getting very slow during login. The fix is to
delete the local users on each of the desktops, which, while easy to
do manually, requires that we touch each machine.
The first step to automate the process was to put together a
WindowsForms app that calls Directory.GetDirectories on the Documents
and Settings folder, and walks through the returned string[] of folder
names and calls Directory.Delete(foldername, true) on each user
folder. The app is smart enough to not try to delete the folder of
user that is currently logged in, the "All Users", "Default User"
folders etc.
I'm running the app on the local machine and I am logged in as a
domain admin but get Access denied exceptions that look like:
Access to path 'c:documents and settings\jsmith\Application Data' is
denied
Access to path 'c:documents and settings\jsmith\Desktop' is denied
Access to path 'c:documents and settings\jsmith\Favorites' is denied
etc.
Oddly, I can manually delete the folders without error. I have
checked my assembly using the ".NET Framework 2.0 Configuration-->My
Computer-->Runtime Security Policy" which lists the permissions
granted to the assembly as "Unrestricted".
Here's an abreviated code snippet:
private void RemoveUserFolders()
{
string[] userFolders = Directory.GetDirectories
(DocsAndSettingsPath);
int folderCount = userFolders.Length;
Console.WriteLine(" Found {0} folders", folderCount);
foreach (string folder in userFolders)
{
try
{
if (IsSpecialFolder(folder))
Console.WriteLine(" Skipping reserved folder: {0}",
folder);
else
{
Console.WriteLine("Deleting user folder: {0}",
folder);
DirectoryInfo dirInfo = new DirectoryInfo(folder);
dirInfo.Delete(true);
}
}
catch (Exception ex)
{
Console.WriteLine(" An exception occurred while deleting
folder [{0}]. Reason: {1}", folder, ex.Message);
}
}
}
Any thoughts as to what might be happening?
offline files. Users can login to any of 50 or so desktops and have
access to their document, desktop setting, etc regardless of which
machine they log in to.
This works very well for our environment but after several months the
desktop machines start getting very slow during login. The fix is to
delete the local users on each of the desktops, which, while easy to
do manually, requires that we touch each machine.
The first step to automate the process was to put together a
WindowsForms app that calls Directory.GetDirectories on the Documents
and Settings folder, and walks through the returned string[] of folder
names and calls Directory.Delete(foldername, true) on each user
folder. The app is smart enough to not try to delete the folder of
user that is currently logged in, the "All Users", "Default User"
folders etc.
I'm running the app on the local machine and I am logged in as a
domain admin but get Access denied exceptions that look like:
Access to path 'c:documents and settings\jsmith\Application Data' is
denied
Access to path 'c:documents and settings\jsmith\Desktop' is denied
Access to path 'c:documents and settings\jsmith\Favorites' is denied
etc.
Oddly, I can manually delete the folders without error. I have
checked my assembly using the ".NET Framework 2.0 Configuration-->My
Computer-->Runtime Security Policy" which lists the permissions
granted to the assembly as "Unrestricted".
Here's an abreviated code snippet:
private void RemoveUserFolders()
{
string[] userFolders = Directory.GetDirectories
(DocsAndSettingsPath);
int folderCount = userFolders.Length;
Console.WriteLine(" Found {0} folders", folderCount);
foreach (string folder in userFolders)
{
try
{
if (IsSpecialFolder(folder))
Console.WriteLine(" Skipping reserved folder: {0}",
folder);
else
{
Console.WriteLine("Deleting user folder: {0}",
folder);
DirectoryInfo dirInfo = new DirectoryInfo(folder);
dirInfo.Delete(true);
}
}
catch (Exception ex)
{
Console.WriteLine(" An exception occurred while deleting
folder [{0}]. Reason: {1}", folder, ex.Message);
}
}
}
Any thoughts as to what might be happening?