@echo off
echo ============================================
echo Reset Windows Update components
echo ============================================
echo.
echo Run this script as Administrator.
echo.

net stop wuauserv
net stop bits
net stop cryptsvc

echo.
echo Renaming Windows Update data directories...

if exist "%windir%\SoftwareDistribution.old" (
    echo SoftwareDistribution.old already exists.
    echo Check the existing backup folder first.
    goto :END
)

if exist "%windir%\System32\catroot2.old" (
    echo catroot2.old already exists.
    echo Check the existing backup folder first.
    goto :END
)

ren "%windir%\SoftwareDistribution" SoftwareDistribution.old
ren "%windir%\System32\catroot2" catroot2.old

echo.
echo Starting services again...

net start cryptsvc
net start bits
net start wuauserv

echo.
echo ============================================
echo Reset completed.
echo Restart Windows and check Windows Update.
echo ============================================
:END
pause
