C盘瘦身命令行方式

保存下面为.bat文件,然后双击执行,就可以为C盘瘦身

net session >nul 2>&1
if not "%errorLevel%" == "0" (
  echo Oops: This tools must run with administrator permissions!
  echo it will popup the UAC dialog, please click [Yes] to continue.
  echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  echo UAC.ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\getadmin.vbs"
  "%temp%\getadmin.vbs"
  exit /b 2
)

@echo off
Dism /online /cleanup-image /restorehealth

chkdsk
sfc /scannow
 
echo cleanup gabarge files, please wait ...

rmdir   %temp% /S /Q
del   %temp% /S /Q

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\*.*"
 
del /f /s /q  "C:\Windows\SoftwareDistribution\Download\*.*"
del /f /s /q  "C:\Program Files\NVIDIA Corporation\Installer2\*.*"
 
echo done!
 
echo. & pause

你可能感兴趣的:(windows)