Cleaning script for windows profile directory

As programs under windows normaly store their user specific data and settings in the profile directory this directory becomes larger and larger with time. In a environment where profile roaming is enabled (which is the case in a default windows centric network) this is a major issue: After successfull login the hole profile directory is copied over from the server to the client and at logout the other way around. Additonally virus scanner slow down the copy process.For these reasons it is eligible to have a minimal amount of data in the profile directory and store the user generated files directly on the server. But even if you do not actively store anything in your profile dir it becomes messed up with files because software stores there its temporary/backup files without cleaning it regulary.

For this purpose I have written a small JScript script cleanwinprofile. It could be runned e.g. everytime a user logs in. For “configuration” you have to edit the source code. Warning: The default could “configuration” deletes some files which you might consider valuable.

Basically you define a couple of directories in your profile you wish to be cleaned together with the number of days for minimum age of the files. An example:

deleteFiles(WshShell.SpecialFolders("Recent"),"",28,0,0);

This let the script look in your recent files folder for entries older than 28 days (modification date is considered) and does no recursing in the directory.

Another example:

deleteFiles(fso.BuildPath(appDataDirname,"Macromedia\\Flash Player"),"",7,1,1);

This looks recursively in the directory where flash player stores its cookies for files older than 7 days and deletes them and their empty parent directories.

And a last one which deletes files in javas cache directory:

deleteFiles(fso.BuildPath(appDataDirname,"Sun\\Java\\Deployment\\Cache"),"",7,1,0);

Please look in the source code for more information. As cleanwinprofile.js deletes files without user intervention you should understand what the code does. You might consider some data more valuable as I.