ICC Home  /  Members  /  Meetings  /  Peer Support  /  Documentation  /  Projects


Windows Automatic Update repair:


Return to IT/SA Services Documentation: Security Tools

With thanks to Joe Gasper...

Automatic Updates can get hosed--sometimes with very odd symptoms such at srchost taking 100% of your processing time. By creating a batch file with the following code, and running it, you can often return things to a working state.

@echo off
::Batch file to reset Automatic Updates on a Windows XP machine
::
::Batchfile based on Microsoft KB for troubleshooting SVCHOST issues
::
::Created By: Santos Soler - 8/15/06

::Stop services if they are running
net stop wuauserv
net stop bits

::Wait 3 seconds
sleep 3

::Rename the folder CatRoot2 to .old or new
if not exist c:\windows\system32\catroot2.old\nul goto movea
move /y c:\windows\system32\CatRoot2 c:\windows\system32\CatRoot2.new
goto continue1

:movea
move /y c:\windows\system32\CatRoot2 c:\windows\system32\CatRoot2.old
goto continue1

:continue1
::Stop Cryptography services
net stop cryptsvc

::Wait 3 seconds
sleep 3

::Rename SoftwareDistribution folder to .old or new 
if not exist %systemroot%\SoftwareDistribution.old\nul goto moveb
move /y %systemroot%\SoftwareDistribution %systemroot%\SoftwareDistribution.new
goto continue2

:moveb
move /y %systemroot%\SoftwareDistribution %systemroot%\SoftwareDistribution.old
goto continue2

:continue2
::Start Cryptography service 
net start cryptsvc

echo.
echo.
echo Registering DLL's...
::Register all the Windows Updates DLL's
REGSVR32 /s WUAPI.DLL
REGSVR32 /s WUAUENG.DLL
REGSVR32 /s WUAUENG1.DLL
REGSVR32 /s ATL.DLL
REGSVR32 /s WUCLTUI.DLL
REGSVR32 /s WUPS.DLL
REGSVR32 /s WUPS2.DLL
REGSVR32 /s WUWEB.DLL
echo Finished registering DLL's...
echo.
echo.

if exist c:\windows\SoftwareDistribution.new\nul goto skipsrvcs
goto startsrvcs

:startsvcs
echo Starting Services...
::Start the Automatic updates and BITs services
net start wuauserv
net start bits
goto wsus

:skipsrvcs
echo Update services were skipped...
goto wsus

:wsus
Echo Forcing reporting to WSUS... 
::Force Windows to report to WSUS
wuauclt /detectnow

::Change the Automatic Update service to automatic
sc config wuauserv start= auto

echo.
echo.
echo Please wait 5-10 minutes for UPDATES, If Service Host Crashes...
pause

::Change the Automatic Update service to manual
sc config wuauserv start= demand

::Restart the computer in 10 seconds
shutdown -r -f -t 10

::Abort the restart
echo.
echo.
echo If you NEED to Abort the restart...
pause

shutdown -a 

last edited 10 October 2006 by Steve Lasley