Over time users tend to open a lot of items programs that write little files to be used just once to print a document or a small setting for a program. These items build up over time and cause your computer to run slower due to your antivirus solution scanning it, your hard drive taking longer to find a free space of disk to write your new file or has to spend more time gathering up fragments of your file from in between these temp files. The solution here is pretty simple, these files need to go, and probably the easiest solution is the remove them when the user logs off. This doesn’t require anymore time for the user and typically isn’t a problem since most computers are logged on and off once a day.
This script will remove the most common temporary folder for the user as well as remove any of the temporary internet files that they have gathered while surfing the web. When we implemented this script we noticed that the antivirus scan time and how many files it scanned were significantly reduced providing a better and faster workstation for your users. This script should be placed in the Group Policy for users as one of their logoff script.
Const TEMPORARY_INTERNET_FILES = &H20& dim intDepth Set objShell = CreateObject("Shell.Application") Set objFSO = CreateObject("Scripting.FileSystemObject") 'Clean User Temporary Intenet Files Set objNameSpace = objShell.Namespace(TEMPORARY_INTERNET_FILES) Set objFolderItem = objNameSpace.Self set objFolder=objFSO.GetFolder(objFolderItem.Path) intDepth=0 RemoveFolder objFolder 'Clean User Temp Files Const TemporaryFolder = 2 Set tempFolder = objFSO.GetSpecialFolder(TemporaryFolder) RemoveFolder tempFolder sub RemoveFolder(objFolder) ' Recursively remove files and folders intDepth=intDepth+1 on error resume next for each objFile in objFolder.Files objFile.Delete true next Err.Clear on error goto 0 for each objSubfolder in objFolder.SubFolders RemoveFolder objSubFolder next intDepth=intDepth-1 if intDepth<>0 then' Don't delete top-level folder on error resume next objFolder.Delete true err.Clear on error goto 0 end if end sub