清除windows 8 中的臨時文件腳本

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


運行結果如下圖

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章