Desktop Folder Cleanup Utility

Sourcepath: nt\shell\applets\cleanup\fldrclnr\
Binary: fldrclnr.dll

Installation directory %windir%\system32\ (NOT YET ADDED TO SETUP)

Entrypoints:  Regsvr32 /i fldrclnr.dll  
         This creates a scheduled task to run it every 60 days by default.
	
                     Rundll32 fldrclnr.dll,Wizard_RunDLL
Launches wizard with a balloon tip user notification in the task bar if there are items to be cleaned. Only shows items that need to be cleaned up.

                     Rundll32 fldrclnr.dll,Wizard_RunDLL all
Launches wizard without notifications. Shows all shortcuts and regitems, marks as selected only the ones that are old.

Registry Settings: (THIS NEEDS TO BE CONFIRMED WITH POLICY TEAM)
Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Desktop\\CleanupWiz	
A DWORD value named “Days between clean up” stores the value to override the default 60 days clean up period.

Description of how it works
	The scheduled task to launch this wizard is created whenever a new user logs in. The name of this task is based on the user’s name, for example, “John Doe’s Desktop Cleanup Monitor”. For the case of different user on different domains having the same user name, we append the user account’s guid to the task name.
	This task is scheduled to run daily, but only if the user is logged on. When this task runs, the first thing it does is that it checks the last run time and finds out how many days its supposed to wait between cleanup (default 60 days, can be overridden by policy).  If those many days have elapsed since it last ran it launches the cleanup process. (The point of the task running daily is that if an administrator changes the policy value, we pick it up within a day, instead of waiting till the wizard runs, which could be as many as 60 days).
	The cleanup process first finds out if there are any unused items on the desktops, by definition, unused items are items that have not been used since the wizard last ran. If there are no such items, it just records the last run and ends. Otherwise, it pops up a notification balloon. The balloon shows up three times, for 10 seconds each with 15 seconds interval in between. If the user does not click on it, we just log the last run time and finish. If the user clicks on the notification, the wizard UI shows up, and guides the user through as per the specs.

	The only items we consider while cleaning up are shortcuts (which support IShellLink interface) and regitems. There is code in defview that tracks this usage, so we have accurate last used times. For shortcuts, we simply move the file to the Unused Desktop Files folder, which the user can drag back if he wants to restore it. We have a slightly complicated procedure for handling regitems, which is explained below.

Cleaning Up Regitems: 
	A regitem is an icon that you see on the desktop because of some settings added to the registry. There is no physical file in the desktop folder for that item. As these kind of regitems can only be created in special registry folders like the desktop folders, there is no way to create them in the Unused Desktop Files folder, which is a normal file system folder. So what we do is that we create a file in Unused Desktop Files folder which has a filename “Name.{CLSID}”, where the CLSID is the CLSID of the registry item. For example, for outlook we will create a file called “Microsoft Outlook. {00020D75-0000-0000-C000-000000000046}”. The cool thing about these .{CLSID} files is that shell treats this objects as special and makes them behave same as the corresponding regitem. So this file will have the same icon and all the right click menu options of the corresponding regitem on the desktop. So, we create this file and mark the regitem as hidden on the desktop. So as far as the user is concerned he just moved this item to the Unused Desktop Filse folder.
	However, this file is not quite the same thing as the regitem, as it has some extra options on the right click menu. So in case the user restores this file from the Unused folder and puts it back on the desktop, we try to restore the regitem when we get a chance. What we do is that whenever the wizard runs, while enumerating all the items on the desktop it actually checks if there is a .{CLSID} file on the desktop. Then it verifies if there is a regitem on the desktop for the CLSID that has been marked as hidden. And then if both the file and the regitem have the same display name, we delete the file and re-enable the regitem.
	Also, because we do not track usage of the .{CLSID} files on the desktop (we potentially could), when we re-enable the regitem we mark it as having been used at that time so that it is not cleaned up again immediately.
	Confused? Please ping me, and I’ll explain it to you.
	
- Arish Ali (10/18/00).