Script to reset Windows Update Services (Windows 7 / Server 2008 R2 and Above)

Script to reset Windows Update Services (Windows 7 / Server 2008 R2 and Above)

@echo off
REM  Automation of Steps to Reset Windows Updates
REM  Tested on Server 2012 R2, likely works on everything Win7/2008R2 and up
REM  by Bret Fisher bret@winsitter.com
REM  Origional Steps (identical to this): http://support.microsoft.com/kb/971058
REM  This file Copyright MIT License

REM Stop Services

net stop bits
net stop wuauserv
net stop appidsvc
net stop cryptsvc

REM Delete the qmgr*.dat files
Del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"

REM If this is first run through, don't run these steps, so ask if first time
SET /P ANSWER=Try 2nd round of deletes (do more stuff) (Y/N)?
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
REM they hit yes, so run these extra 5 lines for 2nd time through
echo You pressed yes, doing more this time!
Ren %systemroot%\SoftwareDistribution SoftwareDistribution.bak
Ren %systemroot%\system32\catroot2 catroot2.bak
sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)

:no
REM Register services (not all of these will work on every OS, no harm done)
cd /d %windir%\system32
regsvr32.exe /s atl.dll
regsvr32.exe /s urlmon.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s browseui.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s scrrun.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s softpub.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s dssenh.dll
regsvr32.exe /s rsaenh.dll
regsvr32.exe /s gpkcsp.dll
regsvr32.exe /s sccbase.dll
regsvr32.exe /s slbcsp.dll
regsvr32.exe /s cryptdlg.dll
regsvr32.exe /s oleaut32.dll
regsvr32.exe /s ole32.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s initpki.dll
regsvr32.exe /s wuapi.dll
regsvr32.exe /s wuaueng.dll
regsvr32.exe /s wuaueng1.dll
regsvr32.exe /s wucltui.dll
regsvr32.exe /s wups.dll
regsvr32.exe /s wups2.dll
regsvr32.exe /s wuweb.dll
regsvr32.exe /s qmgr.dll
regsvr32.exe /s qmgrprxy.dll
regsvr32.exe /s wucltux.dll
regsvr32.exe /s muweb.dll
regsvr32.exe /s wuwebv.dll

REM reset winsock
netsh winsock reset

REM reset proxy
netsh winhttp reset proxy

REM restart services
net start bits
net start wuauserv
net start appidsvc
net start cryptsvc

REM Install the latest Windows Update Agent.
start http://support.microsoft.com/kb/949104
pause