Thursday, October 11, 2007

Folder Redirection: Duplicate User Files Folders

[EDIT] Many of you having duplicate folder issues will be more interested in another article: Folder Redirection: Not to the User's Home Directory [/EDIT 05/11/2007]

I've experienced an odd glitch with Vista User Files Folders that I thought you should be aware of. It seems that when I am changing GPO settings that relate to Offline Files, I end up with duplicate folders in the Users Files Folders (see pic):

I haven't determined a trigger for this yet - they just appear after I have been manipulating my Offline Files GPOs. Thankfully it has only happened in my test environment (although more than once) and not in full blown production - but I see that others on the web have not been so lucky.

In this case the folders are easy to spot because they aren't populated with Desktop.INI files and therefore don't display the green folder icon. In fact, the folders are completely empty. But it is important to remove the folders before your users get confused and start saving things in them.

There is rather strange behavior if you attempt to manually delete the folders using Windows Explorer which I will let you experience for yourself. Instead, you can find these extra folders located in the user's local profile directory %UserProfile%. None of the 13 User Files Folders (with the exception of AppData) should be found in this directory when they are being redirected elsewhere. Delete the extra folders from here.

If you are in the uncomfortable situation of having duplicate folders on workstations spread throughout your organization, you need an automated method for cleaning up these folders. The easiest method I can think of is adding some DOS RD (Remove Directory) commands in the logon script. The RD command is a safe approach because it will only remove empty directories and not jeopardize any user data. To clean up my example, I would use the following commands:

RD %UserProfile%\Documents
RD %UserProfile%\Music
RD %UserProfile%\Videos

These commands will work for any user. They will not remove important directories for users who aren't utilizing Folder Redirection. You may even wish to leave these commands in your logon script permanently as insurance against any future accidental duplication of these folders.

An important note about the AppData folder... You probably should read up on this folder that Vista uses in a rather complex way. AppData is part of the user profile and can be redirected to a network location. But there are some local data folders within the AppData folder that can never be redirected and will stay local. This causes an AppData folder to be present in both the Local Profile folder and also on the redirected network target. Also, this folder is not normally visible in the User Files Folder. But it will appear there if the user ever ventures into the AppData folder. This is because the user had to "Show Hidden Files and Folders" in order to access the AppData folder.

[EDIT] I've got a new blog article up that talks about User Files Folders: What's with all these extra folders? - It provides great details about the AppData folder and Junctions. [/EDIT 06/11/2007]

8 comments:

Anonymous said...

thanks for the info. I'm having fits with this, but I'm afraid I don't quite understand all the network things you discuss. I was trying to copy Documents to my desktop and accidentally hit move instead of copy. I quickly hit cancel, but it moved it anyway. So, I moved it back.

Now,I have two copies of Documents spontaneously appearing, with the exact same names, and the exact same icons. Delete one, it comes back. Sometimes, I have three. Two are in my User account, and both are empty, then I look and I'll find a third on the desktop, full. I'll delete the two in the user account, move the desktop one back, but can't get rid of the problem. Any help would be appreciated,
Best
Byron

DrJBN whoisat Hotmail dothere Com

Gordon Martin said...

Welcome to Vista James! Connected, Clear, Confident indeed.

You'll get in trouble trying to clean things up if you work on those folders from the generic User Files Folders location (the stub that has your name as the label). Vista seems to have logic that recreates what it thinks it needs on the fly.

Instead, check the properties of those folders and see what storage locations they point to. Drill down to those locations via the drive letter (i.e. "Computer\C:\..."). Try deleting the folders from there. Better yet, do it in a CMD prompt - Vista doesn't do so much monkeying around when you work within a CMD window.

In terms of my blog, sorry about the techno babble, but it can't be helped. I try to lead people into the technical discussion by first writing some background articles - I usually mention those articles when heading into really nasty territory - follow the links.

Anonymous said...

Many thanks for the advice. I first went through and removed every shortcut that existed that refered to any of the duplicates. I removed all the duplicates from the command prompt, with the documents in the correct place, I clicked its properties and used the Return to Default button to set it back to its normal place (which is where it was at the moment). So far, I've only one copy!

Thanks for your blog, not much showed up that was useable in my, somewhat limited, google search.

This was really frustrating given that I just spent 2 days reinstalling vista, my software, and all its updateds due to a mysterious hang on CrcDisk.sys issue that seems to plauge some laptop owners. I had to do a full system restore to get my system back. Then, thinking I've got a clean bug free updated system, pow.. multiple Document folders.

Best,
Byron

Gordon Martin said...

We've had to do more than our share of OS builds ourselves. Not nice when the whole process can take the better part of a day now.

Rebuilds become necessary because Vista seems so unpredictable with all the branching decisions it makes. But Microsoft has failed to write any documentation to describe any of those behaviours so your left with no ability to fix anything when it goes squirley. This happened to me often enough that I realized this blog was necessary.

CSC is a good example. I've actually been trying to write an article on CSC for a good 6 months now - but I've been trying to get more useful information on the behaviours out of Microsoft. Those efforts have been fruitless so I'm just going to have to write what I do know soon.

Glad I could help.

Bud said...

Hi there,
Just wondering if you ever came across a situation where running the "RD %UserProfile%\FolderName" command just comes back with an "Access Denied" message on all folders? Deleting the folders from Windows Explorer works fine, but not from a cmd prompt!
Cheers!

Gordon Martin said...

I see that exact same behaviour if I try to delete a folder that is still being used as a User Files Folder. But if I have redirected a User Files Folder to a network server, I have no trouble deleting the old local copy using CMD.

It's probably good that CMD protects you from deleting folders that are still in use. I'm not sure why Explorer allows it to happen though!

I wouldn't recommend deleting folders that are still being used for User Files Folders because there are system variables that take programs right to those locations. I don't know what would happen if they were missing.

Anonymous said...

When I use:
dir /ad
[JUNCTION] My Music [C:\Users\[user]\Music]
[JUNCTION] My Pictures [C:\Users\[user]\Pictures]
[JUNCTION] My Videos [C:\Users\[user]\Videos]

So it seems there are junction points in the folder that prevents it from being deleted from the CMD and also by using RD. From File Explorer it works fine. Not so good when trying to clean up from GPO. How do I prevent these junction points from being created?

Anonymous said...

Well ok, the Documents folder can be removed if you redirect the Pictures, Videos and Music folder to follow Documents folder. Thanks for sharing this particular problem that is difficult to get rid off.
I would recommend on Windows Server 2008 and Vista to also remove the %USERPROFILE%\Music, %USERPROFILE%\Pictures and %USERPROFILE%\Videos folders while these are also available as redirected folders inside the redirected Documents.