当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

作者:精品下载站 日期:2024-12-14 23:19:43 浏览:14 分类:玩电脑

如何重置 Windows 更新组件以修复更新错误


如果 Windows Update 服务无法正常工作,无法下载或安装更新,那么解决 Windows Update 服务问题的最简单、最有效的方法就是恢复其原始设置。在本文中,我们将向您展示如何重置 Windows 更新代理和服务配置。

通常,要调试 Windows Update 错误,管理员需要分析 %windir%\WindowsUpdate.log 文件中的错误代码(在 Windows 10 中,您可以通过这种方式获取 WindowsUpdate.log)。管理员在分析 Windows 更新日志时可能遇到的错误数量有几十个(Windows 更新错误的完整列表),并且解决这些错误的过程并不简单。为了避免不必要的努力并且不浪费时间,将 Windows Update 服务和代理完全重置为默认状态要容易得多。

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

使用 Windows 更新疑难解答修复更新问题

在继续重置 Windows 更新配置之前,我们强烈建议您首先尝试使用更简单且相当有效的工具,使用内置的Windows 更新疑难解答自动修复 Windows 更新服务中的问题。

Windows 更新疑难解答已内置于 Windows 10 和 11 的现代设置面板中。对于以前版本的 Windows,您必须手动下载:

  • Windows 11 — 设置 -> 系统 -> 疑难解答 -> 其他疑难解答 -> Windows 更新;

    [玩转系统] 如何重置 Windows 更新组件以修复更新错误

  • Windows 10 - wu10.diagcab (https://aka.ms/wudiag ) 或运行该工具的本地版本:开始 -> 设置 -> 更新和安全 -> 疑难解答 -> 其他疑难解答 -> Windows 更新(解决阻止您更新 Windows 的问题);

    [玩转系统] 如何重置 Windows 更新组件以修复更新错误

    要快速访问 Windows 故障排除工具,您可以使用 ms-settings URI 命令:

    ms-settings:troubleshoot
  • Windows 7 和 Windows 8.1 - WindowsUpdate.diagcab (https://aka.ms/diag_wu)。

等待 Windows 更新疑难解答程序扫描您的系统并尝试自动修复 Windows 更新和相关组件中的任何错误。

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

就我而言,发现并修复了 Windows 更新数据库中的损坏。之后,仍然需要重新启动计算机并尝试扫描更新。如果未下载或安装更新,请继续执行下一步。

使用 PowerShell 重置 Windows 更新客户端

您可以使用 PSWindowsUpdate PowerShell 模块重置 Windows Update 代理和服务。

从 PSGallery 脚本库在您的计算机上安装模块:

Install-Module -Name PSWindowsUpdate

启用 PowerShell 脚本的执行:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -force

运行命令:

Reset-WUComponents -verbose

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

Reset-WUComponents 命令停止服务、重新注册 DLL 并清理 C:\Windows\SoftwareDistribution 文件夹等。完整的操作日志可用。

VERBOSE: Background Intelligent Transfer Service (BITS)
VERBOSE: Windows Update (wuauserv)
VERBOSE: Application Identity (appidsvc)
VERBOSE: Cryptographic Services (cryptsvc)
Step 2: Delete the qmgr*.dat files
Step 3: Backup software distribution folders
VERBOSE: Renaming Software Distribution folder to C:\Windows\SoftwareDistribution.bak
VERBOSE: Renaming CatRoot  folder to C:\Windows\System32\Catroot2.bak
Step 4: Remove old Windows Update logs
VERBOSE: Deleting the C:\Windows\WindowsUpdate.log files.  
Step 5: Reset Windows Update services
VERBOSE: Reset BITS service
VERBOSE: Reset Windows Update service
Step 6: Reregister dll's
VERBOSE: regsvr32.exe / s atl.dll
VERBOSE: regsvr32.exe / s urlmon.dll
VERBOSE: regsvr32.exe / s mshtml.dll
VERBOSE: regsvr32.exe / s shdocvw.dll
VERBOSE: regsvr32.exe / s browseui.dll
VERBOSE: regsvr32.exe / s jscript.dll
VERBOSE: regsvr32.exe / s vbscript.dll
VERBOSE: regsvr32.exe / s scrrun.dll
VERBOSE: regsvr32.exe / s msxml.dll
VERBOSE: regsvr32.exe / s msxml3.dll
VERBOSE: regsvr32.exe / s msxml6.dll
VERBOSE: regsvr32.exe / s actxprxy.dll
VERBOSE: regsvr32.exe / s softpub.dll
VERBOSE: regsvr32.exe / s wintrust.dll
VERBOSE: regsvr32.exe / s dssenh.dll
VERBOSE: regsvr32.exe / s rsaenh.dll
VERBOSE: regsvr32.exe / s gpkcsp.dll
VERBOSE: regsvr32.exe / s sccbase.dll
VERBOSE: regsvr32.exe / s slbcsp.dll
VERBOSE: regsvr32.exe / s cryptdlg.dll
VERBOSE: regsvr32.exe / s oleaut32.dll
VERBOSE: regsvr32.exe / s ole32.dll
VERBOSE: regsvr32.exe / s shell32.dll
VERBOSE: regsvr32.exe / s initpki.dll
VERBOSE: regsvr32.exe / s wuapi.dll
VERBOSE: regsvr32.exe / s wuaueng.dll
VERBOSE: regsvr32.exe / s wuaueng1.dll
VERBOSE: regsvr32.exe / s wucltui.dll
VERBOSE: regsvr32.exe / s wups.dll
VERBOSE: regsvr32.exe / s wups2.dll
VERBOSE: regsvr32.exe / s wuweb.dll
VERBOSE: regsvr32.exe / s qmgr.dll
VERBOSE: regsvr32.exe / s qmgrprxy.dll
VERBOSE: regsvr32.exe / s wucltux.dll
VERBOSE: regsvr32.exe / s muweb.dll
VERBOSE: regsvr32.exe / s wuwebv.dll
Step 7: Reset WinSock
VERBOSE: netsh winsock reset
Step 8: Reset Proxy
VERBOSE: netsh winhttp reset proxy
Step 9: Start Windows Update services
VERBOSE: Cryptographic Services (cryptsvc)
VERBOSE: Application Identity (appidsvc)
VERBOSE: Windows Update (wuauserv)
VERBOSE: Background Intelligent Transfer Service (BITS)
Step 10: Start Windows Update services
VERBOSE: wuauclt /resetauthorization /detectnow

在“设置”面板中搜索更新,或使用 PowerShell 查找可用的 Windows 更新:

Get-WUList

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

使用重置 Windows 更新工具

重置 Windows 更新工具是另一个用于重置 Windows 更新设置的有用且简单的工具。该脚本曾在 TechNet 上提供。作者目前在 GitHub 上维护着一个存储库 (https://github.com/ManuelGil/Script-Reset-Windows-Update-Tool)。让我们考虑一下如何使用它。

已编译的 wureset.exe 文件 (C++) 或常规批处理脚本可供下载。我更喜欢使用cmd脚本。

  1. 下载ResetWUEng.zip并解压;

  2. 以管理员身份运行ResetWUEng.cmd

  3. 该脚本将检测您的操作系统版本(在我的示例中为 Windows 10)并提供 18 个不同的选项。其中一些与 WU 代理设置的重置没有直接关系,但可用于修复各种 Windows 问题(使用 chkdsk 检查磁盘、使用 DISM 修复 Windows 映像、重置 Winsock、清除临时文件等);

    [玩转系统] 如何重置 Windows 更新组件以修复更新错误

  4. 要重置 Windows 更新,通常使用选项2 - 重置 Windows 更新组件就足够了。2Enter

    [玩转系统] 如何重置 Windows 更新组件以修复更新错误

  5. 从命令行执行 Windows 更新代理手动重置时,该脚本将自动执行我们下面描述的所有操作;

    您可以通过在任何文本编辑器中打开 ResetWUEng.cmd 文件并检查其内容来查看脚本执行的操作。例如,选项 2 会将您发送至 :components 函数。

    [玩转系统] 如何重置 Windows 更新组件以修复更新错误

  6. 完成重置 Windows 更新工具脚本后,重新启动计算机并检查新更新。

ResetWUEng.cmd 脚本是通用的,适用于从 Windows XP 到 Windows 11 的所有 Windows 版本。

使用命令提示符重置 Windows 更新设置

重置 Windows Update 代理和服务配置的过程包含几个步骤。所有描述的操作都在提升的命令提示符下执行。我在单个bat 文件中添加了所有命令。

使用此脚本,您可以完全重置Windows Update的配置并清除本地更新缓存。该脚本适用于 Windows 11/10/8.1/7 和 Windows Server 2022/2019/2016/2012 R2/2008 R2 的工作站。当 Windows 停止下载新更新或更新安装期间出现错误时,此脚本有助于消除最典型的 Windows 更新错误。

确保您计算机上的 Windows 更新设置未使用域或本地组策略进行配置。您可以使用

gpresult

工具或

rsop.msc

显示生成的 GPO 设置。或者您可以根据本指南重置本地 GPO 设置。

让我们逐步考虑一下这个脚本的作用:

  1. 停止 Windows 更新、BITS 和加密服务:

    net stop bits
    net stop wuauserv
    net stop appidsvc
    net stop cryptsvc
    taskkill /im wuauclt.exe /f
    
  2. 从文件夹 %ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\ 中删除服务文件 qmgr*.dat:

    Del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"
  3. 重命名系统文件夹,其中存储配置文件和更新缓存(如有必要,它们可以用作备份)。重新启动更新服务后(

    wuauserv

    ),这些目录将自动重新创建:

    Ren %systemroot%\SoftwareDistribution SoftwareDistribution.bak
    Ren %systemroot%\system32\catroot2 catroot2.bak
  4. 删除旧的 windowsupdate.log 文件:

    del /f /s /q %windir%\windowsupdate.log
  5. 重置 BITS 和 Windows Update 服务的权限(如果服务权限已更改):

    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)
    
  6. 重新注册与BITS和Windows Update相关的系统动态库(DLL)文件:

    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
    
  7. 重置 Winsock 设置:

    netsh winsock reset
  8. 重置系统代理设置:

    netsh winhttp reset proxy
  9. 可选。使用本地 WSUS 服务器时,还可以通过删除注册表项 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate 中的以下参数来重置客户端与 WSUS 服务器的当前绑定:

    REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f
    REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f
    REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
    REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v TargetGroup /f
    REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUServer /f
    REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUStatusServer /f
  10. 启动之前停止的服务:

    
    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
  11. 可选。在某些情况下,您需要安装/重新安装 Windows Update Agent (WUA) 版本。您可以使用 PowerShell 检查计算机上当前的 Windows Update Agent Wuaueng.dll 文件版本:

    ((Get-Item $Env:windir\system32\Wuaueng.dll).VersionInfo).ProductVersion

    您可以在此处下载最新版本的 Windows Update 代理:https://support.microsoft.com/en-us/kb/949104。
    Windows 8.1 -

    7.9.9600

    Windows 8 -

    7.8.9200.16693

    Windows 7的 -

    7.6.7600.256

    [玩转系统] 如何重置 Windows 更新组件以修复更新错误

    使用以下命令强制重新安装 Windows Update Agent:Windows7x86:

    WindowsUpdateAgent-7.6-x86.exe /quiet /norestart /wuforce

    Windows 7 x64:

    WindowsUpdateAgent-7.6-x64.exe /quiet /norestart /wuforce

现在您只需重新启动计算机并与 Windows Update 或 WSUS 运行同步即可。

wuauclt /resetauthorization /detectnow

然后转到 Windows 更新并确保检查、下载和安装更新时没有错误。

可以通过此链接 reset_windows_update_agent.zip 下载 reset_windows_update_agent.bat 脚本(选项 9 和 11 不包含在脚本中,因为它们是可选的)。下载脚本,解压并以管理员身份运行。

[玩转系统] 如何重置 Windows 更新组件以修复更新错误

如果正确下载并安装了 Windows 更新,您可以删除备份文件夹:

Ren %systemroot%\SoftwareDistribution SoftwareDistribution.bak
Ren %systemroot%\system32\catroot2 catroot2.bak

如果所有其他方法均失败,请尝试从 Microsoft 更新目录手动下载并安装适用于您的 Windows 版本的最新累积更新。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯