Skip to content

Instantly share code, notes, and snippets.

@MaxRei-dev
Last active January 18, 2024 23:03
Show Gist options
  • Save MaxRei-dev/8d42bd15c264e803a2bebbe19d076be1 to your computer and use it in GitHub Desktop.
Save MaxRei-dev/8d42bd15c264e803a2bebbe19d076be1 to your computer and use it in GitHub Desktop.
Reset Windows Update Agent
Using this script, you can completely reset the configuration of Windows Update and clear the local update cache. The script is applicable for both workstations with Windows 11/10/8.1/7 and Windows Server 2022/2019/2016/2012 R2/2008 R2. This script helps to eliminate most typical Windows Update errors when Windows stops downloading new updates or errors appear during the update installation.
@echo off
REM Script to Reset Windows Updates agent
REM Stop Services
net stop bits
net stop wuauserv
net stop appidsvc
net stop cryptsvc
taskkill /im wuauclt.exe /f
REM Delete the qmgr*.dat files
Del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"
REM Rename folders
Ren %systemroot%\SoftwareDistribution SoftwareDistribution.bak
Ren %systemroot%\system32\catroot2 catroot2.bak
REM Reset services permissions
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)
sc.exe sdset cryptsvc D:(A;;CCLCSWLOCRRC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCDCLCSWRPWPDTLCRSDRCWDWO;;;SO)(A;;CCLCSWRPWPDTLOCRRC;;;SY)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;WD)
sc.exe sdset trustedinstaller D:(A;;CCLCSWLOCRRC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCDCLCSWRPWPDTLCRSDRCWDWO;;;SO)(A;;CCLCSWRPWPDTLOCRRC;;;SY)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;WD)
REM ReRegister services
cd /d %windir%\system32
regsvr32.exe /U /s vbscript.dll
regsvr32.exe /U /s mshtml.dll
regsvr32.exe /U /s msjava.dll
regsvr32.exe /U /s msxml.dll
regsvr32.exe /U /s actxprxy.dll
regsvr32.exe /U /s shdocvw.dll
regsvr32.exe /U /s Mssip32.dll
regsvr32.exe /U /s wintrust.dll
regsvr32.exe /U /s initpki.dll
regsvr32.exe /U /s dssenh.dll
regsvr32.exe /U /s rsaenh.dll
regsvr32.exe /U /s gpkcsp.dll
regsvr32.exe /U /s sccbase.dll
regsvr32.exe /U /s slbcsp.dll
regsvr32.exe /U /s cryptdlg.dll
regsvr32.exe /U /s Urlmon.dll
regsvr32.exe /U /s Oleaut32.dll
regsvr32.exe /U /s msxml2.dll
regsvr32.exe /U /s Browseui.dll
regsvr32.exe /U /s shell32.dll
regsvr32.exe /U /s atl.dll
regsvr32.exe /U /s jscript.dll
regsvr32.exe /U /s msxml3.dll
regsvr32.exe /U /s softpub.dll
regsvr32.exe /U /s wuapi.dll
regsvr32.exe /U /s wuaueng.dll
regsvr32.exe /U /s wuaueng1.dll
regsvr32.exe /U /s wucltui.dll
regsvr32.exe /U /s wups.dll
regsvr32.exe /U /s wups2.dll
regsvr32.exe /U /s wuweb.dll
regsvr32.exe /U /s scrrun.dll
regsvr32.exe /U /s msxml6.dll
regsvr32.exe /U /s ole32.dll
regsvr32.exe /U /s qmgr.dll
regsvr32.exe /U /s qmgrprxy.dll
regsvr32.exe /U /s wucltux.dll
regsvr32.exe /U /s muweb.dll
regsvr32.exe /U /s wuwebv.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s msjava.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s Mssip32.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s initpki.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 Urlmon.dll
regsvr32.exe /s Oleaut32.dll
regsvr32.exe /s msxml2.dll
regsvr32.exe /s Browseui.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s Mssip32.dll
regsvr32.exe /s atl.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s softpub.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 scrrun.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s ole32.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
sc.exe config wuauserv start= auto
sc.exe config bits start= delayed-auto
sc.exe config cryptsvc start= auto
sc.exe config TrustedInstaller start= demand
sc.exe config DcomLaunch start= auto
net start bits
net start wuauserv
net start appidsvc
net start cryptsvc
REM Install the latest Windows Update Agent.
REM start http://support.microsoft.com/kb/949104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment