windows - 删除临时文件

标签 windows batch-file windows-7 temp

我正在制作一个批处理文件,它可以删除到目前为止我得到的 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

任何人都可以对此进行扩展,以便删除更多临时文件或不需要的文件。所以我可以使它成为一个很好的文件清理器。

最佳答案

不需要的文件是什么意思?另外,为什么不使用 Microsoft 内置的 Disk Cleanup 工具,它的功能远超所需。

您需要谨慎行事,因为 Windows 需要一些临时文件来进行 future 的 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

关于windows - 删除临时文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20490729/

相关文章:

winapi - 带有默认图像/照片查看器的 Windows 7 上的 ShellExecuteEx

ruby-on-rails - 如何使用 Instant Rails 在 Windows 中升级我的 Ruby 版本?

windows - 如何在 Windows 上从 GitHub Desktop 更新 git 版本

c - Windows 生成文件 : generate debug information

java - 从 Oracle 数据库调用批处理脚本/Java 代码

c# - Process.Start cmd.exe 不会运行在 IIS 中运行时作为参数传递的 cmd 文件

c# - 在win7资源管理器中添加一个新列?

c++ - 无法在 Microsoft Visual Studio 中打开 Windows.h

python - 如何从 Python 为当前命令提示符 session 设置环境变量

java - Gradle 运行 bat 文件作为依赖项