Skip to content

Instantly share code, notes, and snippets.

@dieudv
Created February 25, 2019 01:52
Show Gist options
  • Save dieudv/b5dac74e73c007130e66cfcb37d41a47 to your computer and use it in GitHub Desktop.
Save dieudv/b5dac74e73c007130e66cfcb37d41a47 to your computer and use it in GitHub Desktop.
Windows clean scripts. Save with .bat and run as administrator!
@echo off
SETLOCAL ENABLEEXTENSIONS
NET SESSION >nul 2>&1
IF NOT %ERRORLEVEL% EQU 0 (
@echo.
@echo ***************************************
@echo *** YOU NEED RUN AS ANDMINISTRATOR! ***
@echo ***************************************
@goto end
)
call:clf %temp%
call:clf %windir%\Prefetch
call:clf %windir%\Installer
call:clf %windir%\Temp
call:clf %windir%\SoftwareDistribution\download
call:clf %userprofile%\cookies
call:clf %userprofile%\recent
call:clf %windir%\System32\DriverStore
pushd %systemdrive%
rd /s /q %systemdrive%\$Recycle.bin
if exist C:\Windows.old rd /s/q C:\Windows.old
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
echo DONE
pause
@goto end
:clf
pushd %~1
for /R /D %%i in (*) do echo Cleaning %%i && rd /q /s %%i 2> nul
goto:eof
:end
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment