2023年12月23日发(作者:)
磁盘碎片整理自动关机批处理,利用windows自带磁盘整理程序,设计的,可自动清理垃圾文件,自动整理磁盘碎片,整理完成后5分钟自动关机,如不需要关机关闭窗口即可。
步骤:
1.新建文本文档,把下面的程序复制进去,保存退出。
2.再把该文档后缀名更改为bat。
3.使用时双击打开,根据提示输入数字并回车。输入1即可自动完成清理垃圾、整理磁盘碎片、自动关机。
@echo off&color 3e
:ch
cls
echo 请选择:维护项目===================
echo 1 清理垃圾文件
echo 2 整理磁盘碎片
echo 3 待续
echo 4
echo 5
echo 6
echo 7
echo 8
echo 9
echo 0
echo =====================================
set/p aa=请选择序号后回车:
echo.%aa%|findstr "^[0-9]$">nul&&goto M%aa%
goto ch
:M1
REM
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 SettingsTemporary Internet Files*.*"
del /f /s /q "%userprofile%Local SettingsTemp*.*"
del /f /s /q "%userprofile%recent*.*"
@echo off
SET wait=ping -n 2 127.0.0.1 ^>^nul
for /l %%n in (15,-1,0) do (
rem cls
echo =============================
echo.
echo 垃圾文件清理完毕...
echo %%n秒后开始磁盘碎片整理!
echo 不需要整理请关闭窗口...
echo.
echo =============================
%wait%
cls
)
goto M2
)
:M2
rem
defrag c: /f /v
defrag d: /f /v
defrag e: /f /v
defrag f: /f /v
@echo off
SET wait=ping -n 2 127.0.0.1 ^>^nul
for /l %%n in (300,-1,0) do (
rem cls
echo =============================
echo.
echo 磁盘碎片整理完毕...
echo %%n秒后将自动关机!
echo 不需要关机请关闭窗口...
echo.
echo =============================
%wait%
cls
)
shutdown -s -f
)


发布评论