2013-12-10 166 views
1

我正在製作一個批處理文件,可以刪除Windows 7中的所有臨時文件。刪除臨時文件

@echo off 
del /s /f /q "%userprofile%\AppData\Local\Apple Computer\Safari\Cache.db" 
del /s /f /q "%userprofile%\AppData\Local\Apple Computer\Safari\Webpage Previews" 
del /s /f /q "%userprofile%\AppData\Local\Apple Computer\Safari\LocalStorage" 
del /s /f /q "%appdata%\Microsoft\Windows\Recent" 
del /s /f /q "%userprofile%\AppData\Local\Google\CrashReports" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Media Player\Art Cache\LocalMLS" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Media Player\lastplayed.wpl" 
del /s /f /q "%appdata%\Microsoft\Office\Recent" 
del /s /f /q "%userprofile%\AppData\Local\IconCache.db" 
del /s /f /q "%userprofile%\AppData\Local\GDIPFONTCACHEV1.DAT" 
del /s /f /q "%userprofile%\AppData\Local\Opera\Opera" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft Corporation\Windows 7 Upgrade Advisor" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows Mail\Backup" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Caches" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Burn\Burn" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Media Player\Transcoded Files Cache" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Device Metadata\dmrccache\downloads" 
del /s /f /q "%userprofile%\AppData\Local\Diagnostics" 
del /s /f /q "%userprofile%\AppData\Local\CometNetwork\CometBird\Profiles\u4k8vhhn.default\startupCache" 
del /s /f /q "%userprofile%\AppData\Local\CometNetwork\CometBird\Profiles\u4k8vhhn.default\Cache" 
del /q /s /f "%ChromeCache%\*.*">nul 2>&1 
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1 
del /s /f /q "%windir%\setuplog.txt" 
del /s /f /q "%userprofile%\AppData\Roaming\FixCleaner\Logs\" 
del /s /f /q "%windir%\logs\" 
del /s /f /q "%windir%\SoftwareDistribution\DataStore\Logs\" 
del /s /f /q "%Programdata%\AVAST Software\Persistent Data\Avast\Logs\" 
del /s /f /q "%appdata%\.minecraft\crash-reports\" 
del /s /f /q "%userprofile%\AppData\Local\Microsoft\Windows\WindowsUpdate.log" 
del /s /f /q "%windir%\winsxs\x86_microsoft-windows-com-dtc-runtime_31bf3856ad364e35_6.1.7600.16385_none_19295908c15690f3\MSDTC.LOG" 
del /s /f /q "%windir%\System32\SMI\Store\Machine\SCHEMA.DAT.LOG2" 
del /s /f /q "%windir%\system32\LocalGroupAdminAdd.log" 
del /s /f /q "%windir%\system32\Network_LLU.log" 
del /s /f /q "%windir%\system32\Local_LLU.log" 
del /s /f /q "%windir%\system32\InstallPackage_ETW.Log" 
del /s /f /q "%windir%\inf\setupapi.offline.log" 
del /s /f /q "%windir%\Panther\UnattendGCsetuperr.log" 
del /s /f /q "%windir%\System32\sysprep\Panther\IE\setuperr.log" 
del /s /f /q "%windir%\System32\sysprep\Panther\IE\setupact.log" 
del /s /f /q "%windir%\Panther\DDACLSys.log" 
del /s /f /q "%windir%\Panther\setupact.log" 
del /s /f /q "%windir%\Panther\UnattendGC\setupact.log" 
del /s /f /q "%windir%\Microsoft.NET\Framework\v2.0.50727\ngen_service.log" 
del /s /f /q "%windir%\Microsoft.NET\Framework\v2.0.50727\ngen.log" 
del /s /f /q "%windir%\Panther\setuperr.log" 
del /s /f /q "%windir%\Panther\cbs.log" 
del /s /f /q "%windir%\System32\MRT\21063288-61F8-4060-9629-9DBDD77E3242\MpGearSupport_20131019_113721117.log" 
del /s /f /q "%windir%\System32\MRT\21063288-61F8-4060-9629-9DBDD77E3242\MpGearSupport_20131019_115612188.log" 
del /s /f /q "%windir%\System32\Macromed\Flash\install.log" 
del /s /f /q "%windir%\setuperr.log" 
del /s /f /q "%windir%\debug\WIA\wiatrace.log" 
del /s /f /q "%windir%\Performance\WinSAT\winsat.log" 
del /s /f /q "%windir%\SoftwareDistribution\DataStore\Logs\FlashInstall.log" 
del /s /f /q "%windir%\debug\mrt.log" 
del /s /f /q "%windir%\System32\MRT\BA6D0F21-C17B-418A-8ADD-B18289A02461\MpGearSupport_20131208_101543044.log" 
del /s /f /q "%windir%\IE9_main.log" 
del /s /f /q "%windir%\DPINST.LOG" 
del /s /f /q "%windir%\msxml4-KB973688-enu.LOG" 
del /s /f /q "%windir%\Microsoft.NET\Framework\v4.0.30319\HPSLPSVC0007.log" 
del /s /f /q "%windir%\Microsoft.NET\Framework\v4.0.30319\ngen_service.log" 
del /s /f /q "%windir%\IE10_main.log" 
del /s /f /q "%windir%\PFRO.log" 
del /s /f /q "%windir%\SoftwareDistribution\DataStore\Logs\" 
del /s /f /q "%windir%\inf\setupapi.dev.log" 
del /s /f /q "%windir%\SoftwareDistribution\ReportingEvents.log" 
del /s /f /q "%windir%\Logs\CBS\CBS.log" 
del /s /f /q "%windir%\setupact.log" 
del /s /f /q "%windir%\inf\setupapi.app.log" 
del /s /f /q "%windir%\WindowsUpdate.log" 
del /s /f /q "%windir%\SoftwareDistribution\DataStore\Logs\edb.log" 
del /s /f /q %appdata%\.minecraft\crash-reports\*.* /s 
del /s /f /q %Programdata%\AVAST Software\Persistent Data\Avast\Logs\*.* /s 
del /s /f /q %windir%\SoftwareDistribution\DataStore\Logs\*.* /s 
del /s /f /q %windir%\logs\*.* /s 
del /s /f /q %windir%\temp\*.* /s 
del /s /f /q %userprofile%\Local Settings\temp\*.* /s 
del /s /f /q %userprofile%\AppData\Roaming\FixCleaner\Logs\*.* /s 
erase /s/q/f "c:\temp" 
erase /s/q/f "c:\documents and settings\administrator\recent" 
erase /s/q/f "c:\documents and settings\administrator\my recent documents" 
erase /s/q/f "c:\documents and settings\administrator\local settings\my recent documents" 
rmdir /s/q "c:\quarantine" 
erase /s/q/f "%windir%\downloaded program files" 
erase /s/q/f "%windir%\recent" 
erase /s/q/f "%windir%\applog" 
erase /s/q/f "%windir%\desktop\*.tmp" 
erase /s/q/f "c:\documents and settings\administrator\cookies" 
erase /s/q/f "c:\documents and settings\administrator\local settings\history" 
erase /s/q/f "c:\documents and settings\administrator\local settings\temp" 
erase /s/q/f "c:\documents and settings\administrator\local settings\temporary internet files" 
erase /s/q/f "c:\documents and settings\administrator\local settings\application data" 
erase /s/q/f "c:\documents and settings\administrator\userdata" 
erase /s/q/f "c:\documents and settings\administrator\my recent documents" 
erase /s/q/f "%windir%\system32\catroot2\*.log" 
erase /s/q/f "c:\documents and Settings\administrator\application data\mozilla\Profiles\default\mhy0feee.slt\cache" 
erase /s/q/f "c:\documents and Settings\administrator\application data\mozilla\Profiles\default\mhy0feee.slt\cache.Trash" 
erase /s/q/f "c:\documents and Settings\administrator\application data\mozilla\Profiles\default\mhy0feee.slt\cookies.txt" 
erase /s/q/f "c:\documents and settings\administrator\application data\mozilla\Profiles\default\mhy0feee.slt\downloads.rdf" 
erase /s/q/f "c:\documents and settings\administrator\application data\mozilla\Profiles\default\mhy0feee.slt\history.dat" 
erase /s/q/f "c:\documents and settings\administrator\application data\mozilla\Profiles\default\mhy0feee.slt\bookmarks.html" 
erase /s/q/f "%windir%\debug\usermode\userenv.log" 
erase /s/q/f "%windir%\debug\usermode\userenv.bak" 
pause 

任何人都可以展開這個,所以它可以刪除更多的臨時文件或不需要的文件。所以我可以使這個文件更清潔。

+0

我知道我可以和不能刪除,如果我犯了一個錯誤,我可以從Windows安裝盤複製文件。 – 09stephenb

+0

我認爲我也知道自己在做什麼,但我永遠不會做那種事情(並且請注意,您要求其他人_提供刪除位置!)。刪除「隨機」文件幾乎沒有什麼好處和損失。只是因爲某些東西看起來像或者有像「tmp」或「log」這樣的名字並不意味着你真的不需要它。嘗試刪除用戶文件夾中的'ntuser.dat.log1'和'ntuser.dat.log2',如果您感到非常驚喜。你將需要''movefile'工具,因爲它是在你登錄時打開的。但是不要告訴我我沒有提醒你,事後。 – Damon

+0

只是爲了讓你現在我不是這個東西在我的主硬盤驅動器上,我使用了一個分隔符來測試它。所以我可以隨時重新安裝Windows。 – 09stephenb

回答

2

你的意思是不需要的文件是什麼?另外,爲什麼不使用微軟的內置Disk Cleanup工具,它將做得比所需要的多得多。

您需謹慎操作的一點點,因爲一些臨時文件是由Windows爲未來的Windows更新或應用程序更新需要,如果不存在,會導致更新失敗。

- Compression of old files 
- Temporary Internet files 
- Temporary Windows files 
- Downloaded program files 
- Recycle Bin 
- Removal of unused applications or optional Windows components 
- Setup log files 
- Off-line files 
+0

當我說臨時文件時,我只是指任何不需要的東西,它可以節省空間。 – 09stephenb

+1

+1在過去的糟糕時期,我們需要在小型硬盤上節省空間,但是現在您可以獲得比PC上每個臨時文件都大的單個安裝文件。我鼓掌期望應用編程知識,但每隔一段時間刪除臨時文件最好留給磁盤清理。找到對編程更有用的另一項任務。 – foxidrive

1

如果我在寫代碼,以使新的臨時文件清理工具我也將使用變量名稱,如%TEMP%與%WINDIR%,%USERPROFILE%,%APPDATA%等工具如通過piriform在Windows或ccleaner中的Cleanmgr在清理臨時文件方面做得非常出色。我會提醒你在清理臨時文件時不要更改任何屬性,例如刪除只讀訪問等,結果令人不快。舊預取文件和最近的項目不是我在批處理文件中看到的。那些已經在其他批處理文件中的其他網站上提出,例如這個http://community.spiceworks.com/scripts/show/2015-windows-7-temp-file-cleanup-batch-file

0

我開始了喜歡這個它演變成BleachBit的腳本。 您詢問了更多清潔規則,並且加載了所有擴展程序,BleachBit有數千個清潔規則。

BleachBit也有一個命令行界面和JSON,SQLite的,INI文件等專門的清洗方法它是開源的,可擴展的,通常使用XML,可以隨意作出貢獻。