@echo off
:: Check for administrative privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
echo ========================================================
echo ERROR: This script must be run as an Administrator!
echo Please right-click the file and select "Run as administrator".
echo ========================================================
pause
exit /b
)
echo ========================================================
echo Clearing Windows Update History
echo ========================================================
echo.
:: 1. Stop Windows Update Services
echo [*] Stopping Windows Update services...
net stop wuauserv >nul 2>&1
net stop bits >nul 2>&1
net stop cryptsvc >nul 2>&1
echo [+][OK] Services stopped.
echo.
:: 2. Delete the Update History Log
echo [*] Deleting Windows Update history log...
if exist "%ALLUSERSPROFILE%\Microsoft\Network\Downloader" (
del /q /f /s "%ALLUSERSPROFILE%\Microsoft\Network\Downloader\*" >nul 2>&1
)
:: The DataStore.edb file contains the actual history database
if exist "%WINDIR%\SoftwareDistribution\DataStore\DataStore.edb" (
del /f /q "%WINDIR%\SoftwareDistribution\DataStore\DataStore.edb"
echo [+][OK] Update history database deleted.
) else (
echo [-] History database file not found or already deleted.
)
echo.
:: 3. Restart Windows Update Services
echo [*] Restarting Windows Update services...
net start cryptsvc >nul 2>&1
net start bits >nul 2>&1
net start wuauserv >nul 2>&1
echo [+][OK] Services restarted successfully.
echo.
echo ========================================================
echo Process complete! Your update history has been cleared.
echo ========================================================
pause