Batch processing of cleaning up garbage files of Windows Server

Time:2020-7-5
Copy codeThe code is as follows:
@echo off
Echo is cleaning up system garbage files, please wait
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 cleaning system garbage complete!
echo. & pause

Save it as bat suffix.
Practical application value:
When the server has too many logs and garbage files which affect the normal operation of IIS, too many garbage files will affect the running speed of the server
As the server management and maintenance personnel, it is recommended to do a good job of garbage file cleaning.
The following is a detailed description
@Echo off (do not display subsequent commands and the current command line)
Echo is cleaning system garbage files, please wait a moment… (the screen shows “cleaning system garbage files, please wait…”
Del / F / S / Q% SystemDrive% \ *. TMP
del /f /s /q %systemdrive%\*._ MP (forcibly deleting the system is counted in the root directory of the disk_ MP file)
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 \ *. * (forcibly deleting all files in the prefetch folder in the directory of the currently booted system)
Rd / S / Q% windir% \ temp & MD% windir% \ temp (delete the temp folder in the system and create a new temp folder)
Del / F / Q% userprofile% \ cookies \ *. * (delete all files in cookies folder of current user folder)
Del / F / Q% userprofile% \ \ recent \ *. * (delete all files in the recent folder in the current user folder)
Del / F / S / Q% userprofile% \ local settings / temporary Internet files \ *. * “(delete all files in local settings / temporary Internet files \) in the current user folder
Del / F / S / Q% userprofile% \ local settings \ \ temp \ *. * “(delete all files in localsettings / temp \) in the current user folder)
Del / F / S / Q% userprofile% \ recent \ * “(delete all files in the recent folder in the current user folder)
Echo clear system garbage complete! (the screen displays “clear system garbage complete!”)
Echo. & pause (the screen displays “press any key to continue…”) Note: the function of echo. Is to echo a blank line on the screen
————————————————————
@echo off
@Color 1A displays the background and foreground text colors (see below for details)
Echo is cleaning up system garbage files, please wait a moment… Does not work, text display
Del / F / S / Q% SystemDrive% \ \ *. TMP delete all temporary files in the system directory, which are generally useless and left over by the installation software
del /f /s /q %systemdrive%\\*._ MP is the same as above
Del / F / S / Q% SystemDrive% \ \ *. Log deleting log files is generally useless
del /f /s /q %systemdrive%\\*.gid
Del / F / S / Q% SystemDrive% \ \ *. Chk delete windows scan files, which are generally legacy files of chkdisk
Del / F / S / Q% SystemDrive% \ \ *. Old delete extra temporary backup files
Del / F / S / Q% SystemDrive% \ \ recycled \ \ *. * empty recycle bin
Del / F / S / Q% windir% \ \ *. Bak delete windows backup files
del /f /s /q %windir%\\prefetch\\*.*
rd /s /q %windir%\\temp & md %windir%\\temp
Del / F / Q% userprofile% \ \ cookies \ \ *. * deleting cookies left over from the Internet is usually set by windows to speed up the opening of web pages,
Del / F / Q% userprofile% \ \ recent \ \ *. * delete history
Del / F / S / Q \% userprofile% \ \ local settings \ \ temporary Internet files \ \ *. * “delete IE temporary file del / F / S / Q
Del / F / S / Q \% userprofile% \ \ local settings \ \ temp \ \ *. * “delete software temporary files
del /f /s /q \”%userprofile%\\recent\\*.*\”
echo. & pause

Recommended Today

Swift advanced 08: closure & capture principle

closure closurecanCapture and storageOf any constants and variables defined in their contextquote, this is the so-calledClose and wrap those constants and variablesTherefore, it is called“closure”Swift can handle everything for youCaptured memory managementOperation of. Three forms of closure [global function is a special closure]: a global function is a closure that has a name but does […]