以下批处理可以帮助我们对系统上的临时文件和无用的日志或备份文件进行一个清理。
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mpdel /f /s /q %systemdrive%\*.logdel /f /s /q %systemdrive%\*.giddel /f /s /q %systemdrive%\*.chkdel /f /s /q %systemdrive%\*.olddel /f /s /q %systemdrive%\recycled\*.*del /f /s /q %windir%\prefetch\*.*rd /s /q %windir%\temp & md %windir%\tempdel /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\*.*"
在系统清理完成后我们需要调用Defrag命令来对磁盘进行碎片整理。以对C盘进行磁盘整理为例,我们只需执行:
C:\>defrag c:\ -v -f > c:\defrag.txt
命令就可以了。其中-f参数是指如果磁盘空间不足也进行碎片整理。-v参数是指对整理后的磁盘状况结果进行详细描述。然后我用>符号将整理结果重定向到了一个defrag.txt文件中,以便查看。
有了以上两个命令行的磁盘清理和碎片整理的方式,我们就可以通过任务计划来进行定期执行。而不用我们来手动执行了。






