清理Windows伺服器的垃圾檔案的批處理_DOS/BAT

來源:互聯網
上載者:User
複製代碼 代碼如下:

@echo off
echo 正在清理系統垃圾檔案,請稍等......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo 清理系統垃圾完成!
echo. & pause

儲存為bat尾碼的就可以了。
實際應用價值:
針對伺服器突發性的日誌和垃圾檔案過多影響iis的正常運行時,垃圾檔案過多會影響伺服器運行速度
做為伺服器管理和維護人員,建議平時做好垃圾檔案的清理。
以下做詳細說明
@echo off (不顯示後續命令及當前命令列)
echo 正在清除系統垃圾檔案,請稍等...... (螢幕顯示“正在清除系統垃圾檔案,請稍等......”)
del /f /s /q %systemdrive%\*.tmp (強行刪除系統算在磁碟根目錄中副檔名為.tmp的檔案)
del /f /s /q %systemdrive%\*._mp (強行刪除系統算在磁碟根目錄中副檔名為._mp的檔案)
del /f /s /q %systemdrive%\*.log (強行刪除系統算在磁碟根目錄中副檔名為.log的檔案)
del /f /s /q %systemdrive%\*.gid (強行刪除系統算在磁碟根目錄中副檔名為.gid的檔案)
del /f /s /q %systemdrive%\*.chk (強行刪除系統算在磁碟根目錄中副檔名為.chk的檔案)
del /f /s /q %systemdrive%\*.old (強行刪除系統算在磁碟根目錄中副檔名為.old的檔案)
del /f /s /q %systemdrive%\recycled\*.* (清空資源回收筒,如果資源回收筒清空了,這一句其實也派不上用處的)
del /f /s /q %windir%\*.bak (強行刪除當前啟動的系統的所在目錄中副檔名為.bak的檔案)
del /f /s /q %windir%\prefetch\*.* (強行刪除當前啟動的系統的所在目錄中prefetch檔案夾中的所有檔案)
rd /s /q %windir%\temp & md %windir%\temp (將系統中的temp檔案夾刪除後再建立一個temp檔案夾)
del /f /q %userprofile%\cookies\*.* (刪除目前使用者檔案夾中cookies檔案夾中的所有檔案)
del /f /q %userprofile%\recent\*.* (刪除目前使用者檔案夾中recent檔案夾中的所有檔案)
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*" (刪除目前使用者檔案夾中Local Settings\Temporary Internet Files\中的所有檔案)
del /f /s /q "%userprofile%\Local Settings\Temp\*.*" (刪除目前使用者檔案夾中LocalSettings\Temp\中的所有檔案)
del /f /s /q "%userprofile%\recent\*.*" (刪除目前使用者檔案夾中recent檔案夾中的所有檔案)
echo 清除系統垃圾完成! (螢幕顯示“清除系統垃圾完成!”)
echo. & pause (螢幕顯示“Press any key to continue...”)註:echo.的作用是使螢幕上回顯一空行
------------------------------------------------------------
@echo off
@ color 1a 顯示背景和前景文字顏色( 詳細請看下面)
echo 正在清理系統垃圾檔案,請稍等...... 不起作用,文字顯示
del /f /s /q %systemdrive%\\*.tmp 刪除系統目錄下的全部臨時檔案,一般都沒用的,安裝軟體遺留的.
del /f /s /q %systemdrive%\\*._mp 和上面同理
del /f /s /q %systemdrive%\\*.log 刪除記錄檔,一般也沒用
del /f /s /q %systemdrive%\\*.gid
del /f /s /q %systemdrive%\\*.chk 刪除windows掃描檔案,一般是chkdisk 的遺留檔案
del /f /s /q %systemdrive%\\*.old 刪除多餘的臨機操作備份檔案
del /f /s /q %systemdrive%\\recycled\\*.* 清空資源回收筒
del /f /s /q %windir%\\*.bak 刪除windows備份檔案
del /f /s /q %windir%\\prefetch\\*.*
rd /s /q %windir%\\temp & md %windir%\\temp
del /f /q %userprofile%\\cookies\\*.* 刪除上網遺留的cookies一般是windows為了加快網頁開啟速而設定的,
del /f /q %userprofile%\\recent\\*.* 刪除記錄
del /f /s /q \"%userprofile%\\Local Settings\\Temporary Internet Files\\*.*\" 刪除ie臨時檔案del /f /s /q
del /f /s /q \"%userprofile%\\Local Settings\\Temp\\*.*\" 刪除軟體臨時檔案
del /f /s /q \"%userprofile%\\recent\\*.*\"
echo. & pause
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.