Thursday, May 12, 2016

Configuring the recycle bin for redirected folders

Hi all.

Recently, we had the need to disable the recycle bin for all redirected folders. This was due to the fact that the recycle bin - by default - takes a percentage of the volume it is located on, and we redirect to really large volumes, which results in undesirable sizes of these bins... Especially because we charge the users the amount of space they use :-)

Lucky me found a AskDS post that explains the basic steps of managing the recycle bin:
https://blogs.technet.microsoft.com/askds/2012/07/16/managing-the-recycle-bin-with-redirected-folders-with-vista-or-windows-7/

What the AskDS post lacks:
a) What are the folder IDs?
b) How do I deploy the required values?



First, let's determine all the folder IDs. A quick search leads us to https://msdn.microsoft.com/library/dd378457.aspx which lists each and every known folder in Windows. Not all of them can be redirected, but the most common redirected folders are:


Documents{FDD39AD0-238F-46AF-ADB4-6C85480369C7}
Pictures{33E28130-4E1E-4676-835A-98395C3BC3BB}
Videos{18989B1D-99B5-455B-841C-AB7C74E4DDFC}
Music{4BD8D571-6D19-48D3-BE97-422220080E43}
Favorites{1777F761-68AD-4D8A-87BD-30B759FA33DD}
Downloads{374DE290-123F-4565-9164-39C4925E467B}

Folders that are rather rarely redirected include:


AppData{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}
Desktop{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}
Start Menu{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}
Contacts{56784854-C6CB-462b-8169-88E350ACB882}
Links{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}
Searches{7d1d3a04-debb-4115-95cf-2f29da2920da}
Saved Games{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}

For all folders that are redirected we need to create a registry key named with the folder GUID and three values that configure the recycle bin to our needs: Disabled, delete all files - even those that are already present.This requires three REG_DWORD values:
MaxCapacity = 1 (sets the maximum size to 1 MB - zero is not valid)
NukeOnDelete = 1 (delete files immediately)
NeedToPurge = 1 (delete files already present in the bin)

So we have the IDs and the values, now let's deploy them. Create a new GPO and edit, navigate to User Configuration - Preferences - Windows Settings - Registry. Here create three values for each redirected folder as seen in the following screen shot:
The key path is shortened, the full key is Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\KnownFolder\{FDD39AD0-238F-46AF-ADB4-6C85480369C7} which represents the Personal (Documents) folder.

Repeat this as needed (you can copy and paste), then link your new GPO to your users and enjoy a fresh cool afterwork beer :-))

And if you do not want to disable the bin, but only set its size, do not deploy NukeOnDelete and set MaxCapacity to the size in MB you want.

No comments:

Post a Comment