confOS/windows/clean.bat

64 lines
1.6 KiB
Batchfile
Raw Normal View History

2023-04-05 12:36:58 +02:00
@ECHO OFF
2022-12-12 00:08:32 +01:00
:: Start as administrator
2023-04-05 12:38:43 +02:00
fltmc >NUL 2>&1 || (
PowerShell Start -Verb RunAs '%0' 2>NUL || (
EXIT 1
)
EXIT 0
2022-12-12 00:08:32 +01:00
)
2023-02-17 17:13:11 +01:00
ECHO CTMPF :: Clean TeMPorary Files
2022-12-12 00:08:32 +01:00
:: Empty the user's temp folder
2024-07-02 11:19:21 +02:00
ECHO Delete files in %TEMP%...
2024-03-12 09:19:38 +01:00
DEL /S /F /Q %LOCALAPPDATA%\Temp\* 2>NUL
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "%TEMP%" 2>NUL
2022-12-12 00:08:32 +01:00
:: Empty the system's temp folder
2024-07-02 11:19:21 +02:00
ECHO Delete files in %WINDIR%\Temp...
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "%WINDIR%\Temp" 2>NUL
2022-12-12 00:08:32 +01:00
:: Empty the Prefetch folder
2024-07-02 11:19:21 +02:00
ECHO Delete files in %WINDIR%\Prefetch...
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "%WINDIR%\Prefetch" 2>NUL
2022-12-12 00:08:32 +01:00
:: Remove old Windows installation
if exist "%SYSTEMDRIVE%\Windows.old" (
2024-07-02 11:19:21 +02:00
ECHO Delete old Windows installation in %SYSTEMDRIVE%\Windows.old...
TAKEOWN /f "%SYSTEMDRIVE%\Windows.old" /a /r /d y
ICACLS "%SYSTEMDRIVE%\Windows.old" /grant administrators:F /t
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "%SYSTEMDRIVE%\Windows.old"
2022-12-12 00:08:32 +01:00
)
2023-07-09 10:46:33 +02:00
:: Empty useless files of Windows
2024-07-02 11:19:21 +02:00
ECHO Delete files in C:\$WinREAgent...
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "C:\$WinREAgent" 2>NUL
2024-07-02 11:19:21 +02:00
ECHO Delete files in C:\Recovery...
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "C:\Recovery" 2>NUL
2023-07-09 10:46:33 +02:00
2024-02-10 12:06:43 +01:00
:: Empty AMD installer files
2024-07-02 11:19:21 +02:00
ECHO Delete files in C:\AMD...
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "C:\AMD" 2>NUL
2024-02-10 12:06:43 +01:00
:: Empty Windows generated logs
2024-07-02 11:19:21 +02:00
ECHO Delete files in C:\PerfLogs...
2024-02-22 00:26:55 +01:00
RMDIR /S /Q "C:\PerfLogs" 2>NUL
2024-02-22 00:26:51 +01:00
:: Delete Dump
2024-07-02 11:19:21 +02:00
ECHO Delete stack files in C:\DumpStack.log...
2024-02-22 00:26:51 +01:00
DEL /Q "C:\DumpStack.log" 2>NUL
2024-02-10 12:06:43 +01:00
2024-03-12 09:19:46 +01:00
:: Empty NVidia shader caches
2024-07-02 11:19:21 +02:00
ECHO Delete NVidia cache...
2024-03-12 09:19:46 +01:00
DEL /S /F /Q %LOCALAPPDATA%Low\NVIDIA\PerDriverVersion\DXCache\* 2>NUL
DEL /S /F /Q %LOCALAPPDATA%\NVIDIA\GLCache\* 2>NUL
2022-12-12 00:08:32 +01:00
:: Clean disks
2024-07-02 11:19:21 +02:00
ECHO Clean computer with the cleanmgr tool...
2023-02-17 17:13:11 +01:00
CD %WINDIR%\system32
2023-02-17 17:52:53 +01:00
cleanmgr /AUTOCLEAN
cleanmgr /VERYLOWDISK
2023-02-17 17:13:11 +01:00
2023-04-05 12:42:54 +02:00
EXIT /B