Windows Maintenance Made Easy: A Comprehensive Script for Quick Fixes

  • Introduction:
    Is your Windows PC in need of a little TLC [Tender Love Care]?
    Regular maintenance is key to keeping your system healthy and running smoothly. In this blog post, I am excited to share a comprehensive batch script that automates various maintenance tasks provided by Microsoft. 

  • Disclaimer:
    Note: None of the commands in this script were created by Me, I only created the Logic to embed it as a batch script in a single place. These commands are provided by Microsoft. Please verify and ensure the safety of each command before using.

  • What's Included in the Script?
    My maintenance script covers a range of essential tasks, making it a one-stop solution for routine checks and fixes. Users can choose specific tasks using a simple menu interface. Let's take a look at what the script includes:
    • SFC Scan: Verify and repair system files.
    • DISM Scan: Repair Windows images.
    • MRT Check: Run the Microsoft Removal Tool for malware detection.
    • Release & Renew IP Configuration: Manage network configurations.
    • Flush DNS: Clear and reset the DNS resolver cache.
    • Remove Temporary Files: Clean up unnecessary temporary files.
    • Check Disk (Chkdsk): Scan and fix file system issues.
    • Disk Cleanup: Free up disk space by removing unnecessary files.
    • System Information: Access detailed information about your system.
    • Windows Update: Open the Windows Update settings.
    • Event Viewer: Analyze system and application logs.
    • Performance Monitor: Monitor system performance.
    • Task Manager: View and manage running processes.
    • System Configuration: Configure startup programs and services.
    • Power Configuration: Adjust power plans and settings.
    • Driver Verifier Manager: Identify problematic drivers.
    • Windows Memory Diagnostic: Check for memory-related issues.

  • How to Use the Script ?
    1. Open " Notepad " application from your Windows system.
    2. Copy the Script mentioned below from the section " The Maintenance Script " & paste it in the notepad
    3. Once done Click on " File -> Save As " from top left corner of your notepad screen window


    4. You will see a pop-up screen goto " Save as type -> click on the dropdown -> All Files "
    5. Rename the File name as " Name of the file.bat "; that is just keep an extension of ".bat" at the end of the filename.


    6. Once done with the points 4&5 click on " Save ".

    7. Note: Some scripts / commands may need admin rights to run so, Right-click on the script file and select "Run as administrator" to ensure administrative privileges.
    8. Follow the Instructions: The script will guide you through each selected task.
    9. Choose Your Task: Enter the number corresponding to the maintenance task you want to perform.

    10. The Script will look like this once all the steps are followed




  • Conclusion:
    Automating Windows maintenance has never been easier. Use our script to perform routine checks and fixes without the hassle. We encourage you to test the script in a safe environment and share your feedback with us.
    Happy maintaining! 

  • The Maintenance Script👇🏽👇🏽Script mentioned below 👇🏽👇🏽
@echo off
color 0A
title Maintenance Script

:menu
cls
echo.
echo ============================
echo  Windows Maintenance Script Menu
echo ============================
echo  1. Run SFC Scan (Admin Priv Recommended)
echo  2. Run DISM Scan (Admin Priv Recommended)
echo  3. Run MRT Check (Admin Priv Recommended)
echo  4. IP Release_Renew Network Configuration (Admin Priv Recommended)
echo  5. Flush DNS
echo  6. Remove Temporary Files
echo  7. Check Disk (Chkdsk)(Admin Priv Recommended)
echo  8. Disk Cleanup (Admin Priv Recommended)
echo  9. System Information
echo 10. Windows Update
echo 11. Event Viewer
echo 12. Performance Monitor
echo 13. Task Manager
echo 14. System Configuration (Admin Priv Recommended)
echo 15. Power Configuration (Admin Priv Recommended)
echo 16. Driver Verifier Manager (Admin Priv Recommended)
echo 17. Windows Memory Diagnostic
echo 18. Exit

powershell -Command "& {Write-Host '==============================================================' -ForegroundColor DarkYellow; Write-Host 'Maintenance Script - Disclaimer' -ForegroundColor DarkYellow; Write-Host '==============================================================' -ForegroundColor DarkYellow; Write-Host ''; Write-Host '** NOTE: None of the commands in this script were created by Me. These commands are provided by Microsoft.**' -ForegroundColor Red; Write-Host '==============================================================' -ForegroundColor DarkYellow; Write-Host ''}"

set /p choice=__---__" Enter the task number you want to perform "__---__: 

if "%choice%"=="1" goto sfc
if "%choice%"=="2" goto dism
if "%choice%"=="3" goto mrt
if "%choice%"=="4" goto ipconfig
if "%choice%"=="5" goto flushdns
if "%choice%"=="6" goto cleantemp
if "%choice%"=="7" goto chkdsk
if "%choice%"=="8" goto diskcleanup
if "%choice%"=="9" goto systeminfo
if "%choice%"=="10" goto windowsupdate
if "%choice%"=="11" goto eventviewer
if "%choice%"=="12" goto perfmon
if "%choice%"=="13" goto taskmanager
if "%choice%"=="14" goto msconfig
if "%choice%"=="15" goto powercfg
if "%choice%"=="16" goto verifier
if "%choice%"=="17" goto memorydiagnostic
if "%choice%"=="18" goto exit

goto menu

:sfc
cls
echo ============================
echo  Running SFC Scan...
echo ============================
sfc /scannow
pause
goto menu

:dism
cls
echo ============================
echo  Running DISM Scan...
echo ============================
DISM.exe /Online /Cleanup-image /Restorehealth
pause
goto menu

:mrt
cls
echo ============================
echo  Running MRT Check...
echo ============================
start /wait C:\Windows\System32\MRT.exe /F
echo MRT Check completed.
pause
goto menu

:ipconfig
cls
echo ============================
echo  Releasing and Renewing IP Configuration...
echo ============================

:: Check for administrative privileges
NET SESSION >nul 2>&1
if %errorLevel% == 0 (
    echo Running with administrative privileges
    ipconfig /release
    ipconfig /renew
) else (
    echo Please run the script as an administrator to renew the IP configuration.
)

pause
goto menu

:flushdns
cls
echo ============================
echo  Flushing DNS...
echo ============================
ipconfig /flushdns
pause
goto menu

:cleantemp
cls
echo ============================
echo  Removing Temporary Files...
echo ============================
del /q %temp%\*.*
echo Temporary files removed.
pause
goto menu

:chkdsk
cls
echo ============================
echo  Running Check Disk (Chkdsk)...
echo ============================
chkdsk /f
pause
goto menu

:diskcleanup
cls
echo ============================
echo  Running Disk Cleanup...
echo ============================
cleanmgr
goto menu

:systeminfo
cls
echo ============================
echo  Opening System Information...
echo ============================
msinfo32
goto menu

:windowsupdate
cls
echo ============================
echo  Opening Windows Update...
echo ============================
control /name Microsoft.WindowsUpdate
goto menu

:eventviewer
cls
echo ============================
echo  Opening Event Viewer...
echo ============================
eventvwr
goto menu

:perfmon
cls
echo ============================
echo  Opening Performance Monitor...
echo ============================
perfmon
goto menu

:taskmanager
cls
echo ============================
echo  Opening Task Manager...
echo ============================
taskmgr
goto menu

:msconfig
cls
echo ============================
echo  Opening System Configuration...
echo ============================
msconfig
goto menu

:powercfg
cls
echo ============================
echo  Opening Power Configuration...
echo ============================
powercfg.cpl
goto menu

:verifier
cls
echo ============================
echo  Opening Driver Verifier Manager...
echo ============================
verifier
goto menu

:memorydiagnostic
cls
echo ============================
echo  Opening Windows Memory Diagnostic...
echo ============================
mdsched
goto menu

:exit
cls
echo ============================
echo  Exiting...
echo ============================

Comments