IE浏览器在运行长时间后,将会产生很多临时文件,这些临时文件将会使IE浏览器变得越来越慢。同样,系统在运行长时间后,也将产生很多的临时文件,但手动地删除一些临时文件并不是一件太容易事情。在XP和Win7时代有清除临时文件的脚本,现在windows 8 用了一段时间发现除去360之类的工具可以清除,但是又不想装这么多软件,后来找了一个好的脚本来做这个工作。脚本如下保存成PS1的即可

Function Clear-OSCTempFile 

#This function is used to delete temp files such as Internet temp file in windows 8 
#Get all items with ".tmp" in the $env:TEMP path 
$TempFiles =Get-ChildItem-Path $env:TEMP -Recurse | Where-Object {$_.Extension -contains ".tmp" }  
#Call the function to delete them
    DeleteTemp $TempFiles
#Get all items with ".tmp" in Temporary Internet Files 
$InternetTempPath = "C:\Users\$env:USERNAME\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$InternetTmpFilesGet-ChildItem-Path  $InternetTempPath-Recurse |Where-Object {$_.Extension -contains ".tmp"
#Call the function to delete them
    DeleteTemp $InternetTmpFiles


运行结果如下图

清除windows 8 中的临时文件脚本