清空临时文件夹和回收站的脚本    
'********************************************‘ 功能: 清空临时文件夹和回收站等‘********************************************Option ExplicitOn Error Resume Next

Call ClrTmpFiles()    ‘清空临时文件夹 TEMP_FILESCall ClrRecycleBin()  ‘清空回收站 RECYCLE_BIN‘Call ClrIECache()     ‘清空ie缓存 TEMPORARY_INTERNET_FILES

‘msgbox "done!"WScript.Quit

‘————————————————-Sub ClrTmpFiles() ‘清空临时文件夹 On Error Resume Next Dim fso Set fso = CreateObject("Scripting.FileSystemobject")

‘ 清空用户Temp文件夹 Call ClrFolderFiles(fso.GetSpecialFolder(2)) ‘ 清空系统Temp文件夹 Call ClrFolderFiles("C:\WINDOWS\Temp")

Set fso = NothingEnd Sub

‘————————————————-Sub ClrFolderFiles(oFolderPath) ‘清空指定文件夹 On Error Resume Next Dim fso, oSHFolder, oSHFItem Set fso = CreateObject("Scripting.FileSystemobject")

Set oSHFolder = fso.GetFolder(oFolderPath)

For Each oSHFItem In oSHFolder.Files          ‘删除文件 fso.DeleteFile oSHFItem.Path,True Next For Each oSHFItem In oSHFolder.SubFolders  ‘删除子目录 fso.DeleteFolder oSHFItem.Path,True Next

Set oSHFolder = Nothing Set fso = NothingEnd Sub

‘————————————————-Sub ClrIECache()  ‘清空ie缓存  TEMPORARY_INTERNET_FILES On Error Resume Next Const TEMPORARY_INTERNET_FILES = &H20& Dim objShell, objFolder, objFolderItem, strPath, objFSO

Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES) Set objFolderItem = objFolder.Self strPath = objFolderItem.Path & "\*.*"

Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFile(strPath) Set objFSO = NothingEnd Sub

‘————————————————-Sub ClrRecycleBin()  ‘清空回收站 On Error Resume Next Dim oShell, oSHFolder, objFSO, oSHFItem, FilePath

Set oShell = CreateObject("Shell.Application") Set oSHFolder = oShell.Namespace(&Ha&) Set objFSO = CreateObject("Scripting.FileSystemobject")

FOR each oSHFItem IN oSHFolder.Items IF (oSHFItem.type = "File Folder") THEN  ‘删除文件夹 FilePath = oSHFItem.Path objFSO.DeleteFolder FilePath,True ELSE                                     ‘删除文件 FilePath = oSHFItem.Path objFSO.DeleteFile FilePath,True End IF NEXT

Set objFSO = Nothing Set oshell = Nothing Set oSHFolder = NothingEND Sub‘—————–== END ==——————

关联文档