๐ ️ System Integrity Check with a Batch File: A Practical Guide
Author: Mark Warren Van Dyke
Date: September 11, 2025
Tags: Batch scripting, system maintenance, SSD health, DISM, SFC, CrystalDiskInfo, modular logic
๐งญ Why This Exists
This batch file performs a basic system integrity check using built-in Windows tools and CrystalDiskInfo. It’s designed for everyday users—not sysadmins, not PowerShell experts. Just people who want to run a clean check, log the results, and move on.
PowerShell offers more control and flexibility, but this script sticks to batch for accessibility. No modules, no syntax traps. Just commands.
๐ What It Does
- Cleans up superseded updates
- Repairs Windows image health
- Scans system files for corruption
- Checks SSD SMART health (optional)
- Logs everything to a timestamped file
- Reboots the system after a countdown
๐งฑ The Batch File
Copy and paste the following into Notepad. Save it as SystemCheck.bat on your desktop.
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: === Setup log file in same folder as script ===
SET LOGFILE=%~dp0System_Integrity_%DATE:/=-%_%TIME::=-%.log
:: === Initial delay before starting ===
timeout /t 10 >nul
:: === Log and display start timestamp ===
ECHO === System Integrity Check Started: %DATE% %TIME% ===
ECHO === System Integrity Check Started: %DATE% %TIME% === >> "%LOGFILE%"
:: === STEP 1: StartComponentCleanup ===
ECHO [1/4] Cleaning up superseded updates...
ECHO [1/4] Cleaning up superseded updates... >> "%LOGFILE%"
DISM /Online /Cleanup-Image /StartComponentCleanup >> "%LOGFILE%" 2>&1
timeout /t 5 >nul
:: === STEP 2: RestoreHealth ===
ECHO [2/4] Restoring health of component store...
ECHO [2/4] Restoring health of component store... >> "%LOGFILE%"
DISM /Online /Cleanup-Image /RestoreHealth >> "%LOGFILE%" 2>&1
timeout /t 5 >nul
:: === STEP 3: SFC Scan ===
ECHO [3/4] Scanning system files for corruption...
ECHO [3/4] Scanning system files for corruption... >> "%LOGFILE%"
SFC /SCANNOW >> "%LOGFILE%" 2>&1
timeout /t 5 >nul
:: === STEP 4: CrystalDiskInfo SMART Check ===
ECHO [4/4] Checking SSD SMART health via CrystalDiskInfo...
ECHO [4/4] Checking SSD SMART health via CrystalDiskInfo... >> "%LOGFILE%"
SET CDI_PATH="C:\Program Files\CrystalDiskInfo\DiskInfo64.exe"
IF EXIST %CDI_PATH% (
%CDI_PATH% /CopyExit
IF EXIST "%ProgramFiles%\CrystalDiskInfo\DiskInfo.txt" (
ECHO --- SMART Health Summary ---
ECHO --- SMART Health Summary --- >> "%LOGFILE%"
findstr /C:"Health Status" "%ProgramFiles%\CrystalDiskInfo\DiskInfo.txt" >> "%LOGFILE%"
findstr /C:"Temperature" "%ProgramFiles%\CrystalDiskInfo\DiskInfo.txt" >> "%LOGFILE%"
) ELSE (
ECHO CrystalDiskInfo output not found.
ECHO CrystalDiskInfo output not found. >> "%LOGFILE%"
)
) ELSE (
ECHO CrystalDiskInfo not found at expected path.
ECHO CrystalDiskInfo not found at expected path. >> "%LOGFILE%"
)
timeout /t 5 >nul
:: === Final log entry ===
ECHO === System Integrity Check Complete: %DATE% %TIME% ===
ECHO === System Integrity Check Complete: %DATE% %TIME% === >> "%LOGFILE%"
:: === Visual countdown before reboot ===
ECHO.
ECHO System will reboot in 60 seconds. Press CTRL+C to cancel.
timeout /t 60
:: === Reboot ===
ECHO Rebooting now...
shutdown /r /t 0
๐ What You’ll See
In the command window (must be run as administrator):
[1/4] Cleaning up superseded updates...
[2/4] Restoring health of component store...
[3/4] Scanning system files for corruption...
[4/4] Checking SSD SMART health via CrystalDiskInfo...
In the log file (saved to your desktop):
Health Status : Good (98 %)
Temperature : 34 C (93 F)
If CrystalDiskInfo isn’t installed, the script logs that and moves on. No errors, no drama.
๐งช Optional: Replace or Remove CrystalDiskInfo
If you prefer another SMART tool, swap out the logic in Step 4. If you don’t want SSD checks at all, delete that section. The rest of the script runs fine without it.
๐ Why Not PowerShell?
PowerShell could handle this with more finesse — progress bars, error handling, object parsing. But this batch file is built for simplicity. No learning curve. No dependencies. Just run it.
๐งต Final Notes
- You can run this as-is, or tweak it to fit your system.
- Log files are timestamped and saved wherever the batch file is located.
- You can archive them, inspect them, or delete them. Your call.
- The reboot at the end is optional — just remove those lines if you prefer manual control.

No comments:
Post a Comment