System Cleanup Menu

System cleanup menu using Batch scripting in Windows for delete temporary files, prefetch files, recent files, printers spool files and more.
 avatar
DMods
batchfile
2 years ago
7.2 kB
11
Indexable
@echo off
color 0A
title System Cleanup
echo.
echo            ================================
echo            ===       System Cleanup     ===
echo            ================================
echo.
echo                 Author: DMods
echo.

:menu
echo            1. Delete Temporary Files
echo            2. Delete Prefetch Files
echo            3. Delete Recent Files
echo            4. Delete Printers' Spool Files
echo            5. Advanced System Cleanup
echo            6. Exit
echo.

set /p choice=Enter your choice (1-6):

if "%choice%"=="1" (
    echo.
    echo Deleting Temporary Files...
    del /s /f /q c:\windows\temp\*.*
    del /s /f /q C:\WINDOWS\Prefetch
    del /s /f /q %temp%\*.*
    deltree /y c:\windows\tempor~1
    deltree /y c:\windows\temp
    deltree /y c:\windows\tmp
    deltree /y c:\windows\ff*.tmp
    echo.
    echo Temporary files deleted successfully.
    pause
    goto menu
)

if "%choice%"=="2" (
    echo.
    echo Deleting Prefetch Files...
    del /s /f /q C:\WINDOWS\Prefetch
    echo.
    echo Prefetch files deleted successfully.
    pause
    goto menu
)

if "%choice%"=="3" (
    echo.
    echo Deleting Recent Files...
    del /s /f /q c:\windows\recent
    del /s /f /q c:\windows\history
    del /s /f /q c:\windows\cookies
    echo.
    echo Recent files deleted successfully.
    pause
    goto menu
)

if "%choice%"=="4" (
    echo.
    echo Deleting Printers' Spool Files...
    deltree /y c:\windows\spool\printers
    echo.
    echo Printers' spool files deleted successfully.
    pause
    goto menu
)

if "%choice%"=="5" goto advanced_menu

if "%choice%"=="6" (
    echo.
    echo Exiting the program...
    exit
)

echo.
echo Invalid choice. Please try again.
pause
goto menu


:advanced_menu
@echo off
title System Cleanup
color 0A

:menu
cls
echo.
echo            ================================
echo            === Advanced System Cleanup ===
echo            ================================
echo.
echo                 Author: DMods
echo.
echo     1. Clean temporary files
echo     2. Clear recycle bin
echo     3. Clean DNS cache
echo     4. Run Disk Cleanup
echo     5. Uninstall Programs
echo     6. Disable Startup Programs
echo     7. Check for System Updates
echo     8. Update Drivers
echo     9. Clean Browser Cache
echo    10. Clean Recent Documents
echo    11. Delete Temporary Internet Files
echo    12. Empty Downloads Folder
echo    13. Remove Old System Restore Points
echo    14. Clean Clipboard
echo    15. Delete Windows Update Cache
echo    16. Back to System Cleanup
echo    17. Exit
echo.

set /p choice=Enter your choice: 

if "%choice%"=="1" goto clean_temp
if "%choice%"=="2" goto clear_recycle_bin
if "%choice%"=="3" goto clean_dns_cache
if "%choice%"=="4" goto run_disk_cleanup
if "%choice%"=="5" goto uninstall_programs
if "%choice%"=="6" goto disable_startup_programs
if "%choice%"=="7" goto check_system_updates
if "%choice%"=="8" goto update_drivers
if "%choice%"=="9" goto clean_browser_cache
if "%choice%"=="10" goto clean_recent_documents
if "%choice%"=="11" goto delete_temp_internet_files
if "%choice%"=="12" goto empty_downloads_folder
if "%choice%"=="13" goto remove_system_restore_points
if "%choice%"=="14" goto clean_clipboard
if "%choice%"=="15" goto delete_windows_update_cache
if "%choice%"=="16" goto menu
if "%choice%"=="17" exit

:clean_temp
echo.
echo Cleaning temporary files...
del /q /s %TEMP%\*.*
echo.
echo Temporary files cleaned.
pause
goto menu

:clear_recycle_bin
echo.
echo Clearing recycle bin...
rd /s /q C:\$Recycle.Bin
echo.
echo Recycle bin cleared.
pause
goto menu

:clean_dns_cache
echo.
echo Cleaning DNS cache...
ipconfig /flushdns
echo.
echo DNS cache cleaned.
pause
goto menu

:run_disk_cleanup
echo.
echo Running Disk Cleanup...
cleanmgr /sagerun:1
echo.
echo Disk Cleanup completed.
pause
goto menu

:uninstall_programs
echo.
echo Opening Programs and Features...
control appwiz.cpl
echo.
echo Programs and Features closed.
pause
goto menu

:disable_startup_programs
echo.
echo Listing startup programs...

echo Available startup programs:

for /f "skip=1 tokens=1,2 delims=|" %%G in ('wmic startup get Caption^, Description ^| findstr /r /v "^$"') do (
    echo %%G - %%H
)

echo.
echo Enter the name of the program to disable:

set /p program_name=

echo Disabling %program_name%...
start "" "Taskkill" /f /im "%program_name%.exe"
echo %program_name% disabled.
pause
goto menu

:check_system_updates
echo.
echo Checking for system updates...

:: Check if PSWindowsUpdate module is installed
powershell.exe -Command "If (Get-Module -ListAvailable -Name PSWindowsUpdate) {Invoke-Expression -Command 'Get-WindowsUpdate -Online -Quiet'} Else {Write-Host 'The PSWindowsUpdate module is not installed.'}"

set /p install_module=Do you want to install the PSWindowsUpdate module? (Y/N): 
if /i "%install_module%"=="Y" (
    powershell.exe -Command "Install-Module -Name PSWindowsUpdate -Force"
    echo.
    echo The PSWindowsUpdate module has been installed.
    echo.
    pause
    goto check_system_updates
)

echo.
echo System updates checked successfully.
pause
goto menu

:update_drivers
echo.
echo Listing installed drivers...
driverquery /v
echo.
set /p driver=Enter the driver name to update: 
echo.
echo Driver updated.
pause
goto menu

:clean_browser_cache
echo.
echo Cleaning browser cache...

echo Available browsers:
echo 1. Google Chrome
echo 2. Mozilla Firefox
echo 3. Microsoft Edge

set /p browser_choice=Enter your choice (1-3): 

if "%browser_choice%"=="1" (
    echo Cleaning Google Chrome cache...
    start "" chrome.exe --clear-cache
)

if "%browser_choice%"=="2" (
    echo Cleaning Mozilla Firefox cache...
    start "" firefox.exe -purgecaches
)

if "%browser_choice%"=="3" (
    echo Cleaning Microsoft Edge cache...
    start "" msedge.exe --clear-browsing-data
)

echo.
echo Browser cache cleaned.
pause
goto menu

:clean_recent_documents
echo.
echo Cleaning recent documents...
del /q %USERPROFILE%\Recent\*
echo.
echo Recent documents cleaned.
pause
goto menu

:delete_temp_internet_files
echo.
echo Deleting temporary internet files...
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
echo.
echo Temporary internet files deleted.
pause
goto menu

:empty_downloads_folder
echo.
echo Emptying downloads folder...
del /q %USERPROFILE%\Downloads\*.*
echo.
echo Downloads folder emptied.
pause
goto menu

:remove_system_restore_points
echo.
echo Removing old system restore points...
vssadmin delete shadows /for=c: /oldest
echo.
echo Old system restore points removed.
pause
goto menu

:clean_clipboard
echo.
echo Cleaning clipboard...
echo off | clip
echo.
echo Clipboard cleaned.
pause
goto menu

:delete_windows_update_cache
echo.
echo Deleting Windows Update cache...
net stop wuauserv
rmdir /s /q %windir%\SoftwareDistribution
net start wuauserv
echo.
echo Windows Update cache deleted.
pause
goto menu
Editor is loading...