CODE: Delete Temporary Internet files

Option Explicit

‘ Variables

Dim objWSH, sProfile, objFolder Dim objFSO, sProfileRoot, objProfileFolder Dim sTemp, sWindows

‘ Object Initialisation   set objFSO=CreateObject(“Scripting.FileSystemObject”)   ‘ Get user profile root folder

set objWSH    = CreateObject(“WScript.Shell”) sTemp = objWSH.ExpandEnvironmentStrings(“%TEMP%”) sWindows = objWSH.ExpandEnvironmentStrings(“%WINDIR%”) sProfile = objWSH.ExpandEnvironmentStrings(“%USERPROFILE%”) sProfileRoot=objFSO.GetFolder(sProfile).ParentFolder.Path set objWSH=nothing

‘ Main Code   set objProfileFolder=objFSO.GetFolder(sProfileRoot) for each objFolder in objProfileFolder.SubFolders         select case LCase(objFolder.Name)                 case “all users”:                 case “default user”:                 case “localservice”:                 case “networkservice”:                 case else:                         sProfile=sProfileRoot & “\” & objFolder.Name                         DeleteFolderContents sProfile & “\Local Settings\Temp”    DeleteFolderContents sProfile & “\Local Settings\Temporary Internet Files”    DeleteFolderContents sProfile & “\Cookies”

end select next

DeleteFolderContents sTemp DeleteFolderContents sTemp

‘ Function   sub DeleteFolderContents(strFolder)         ‘ Deletes all files in the specified folder and subfolders, but doesn’t delete folders         dim objFolder, objFile, objSubFolder         on error resume next                 set objFolder=objFSO.GetFolder(strFolder)         if Err.Number<>0 then                 Err.Clear                 Exit sub         end if         for each objSubFolder in objFolder.SubFolders                 objSubFolder.Delete true         next         for each objFile in ObjFolder.Files                 objFile.Delete true         next         Err.Clear         end sub