如何在 Windows 10 中重置 Windows Update 更新功能

Windows Update 通过下载和安装 Microsoft 发布的最新更新,驱动程序和修补程序来保持 Windows 10 的更新。有时您可能会遇到 Windows Update 问题,例如无法下载或安装更新,错误消息,无法搜索新更新等。当 Windows Update 数据库或组件损坏,与 Windows Update 相关的一项或多项服务未运行等等。

如何在 Windows 10 中重置 Windows Update 更新功能

如何在 Windows 10 中重置 Windows Update 更新功能

重置 Windows Update 组件通常可以解决这些类型的问题。

另请参阅:Windows Update 其他资源 | 微软文档

1
https://docs.microsoft.com/en-us/windows/deployment/update/windows-update-resources

本教程大眼仔旭(www.dayanzai.me)将向您展示如何将 Windows Update 组件和策略完全重置为 Windows 10 中的默认设置。

复制以下代码,在桌面新建空白文本并粘贴保存,修改 .txt 后缀更改为 .bat 后保存。然后,以管理员身份运行该批处理命令即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@echo off
:: 提示以管理员身份运行
Set "Variable=0" & if exist "%temp%/getadmin.vbs" del "%temp%/getadmin.vbs"
fsutil dirty query %systemdrive%  >nul 2>&1 && goto :(Privileges_got)
If "%1"=="%Variable%" (echo. &echo. Please right-click on the file and select &echo. "Run as administrator". &echo. Press any key to exit. &pause>nul 2>&1& exit)
cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%Variable%", "", "runas", 1 > "%temp%/getadmin.vbs"&cscript //nologo "%temp%/getadmin.vbs" & exit
:(Privileges_got)

:: 检查并停止 Windows Update 服务
set b=0

:bits
set /a b=%b%+1
if %b% equ 3 (
   goto end1
)
net stop bits
echo 检查位服务状态。
sc query bits | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto bits
)
goto loop2

:end1
cls
echo.
echo 由于“后台智能传输服务”(位)服务无法停止,因此无法重置 Windows Update。请重新启动计算机,然后重试。
echo.
pause
goto Start


:loop2
set w=0

:wuauserv
set /a w=%w%+1
if %w% equ 3 (
   goto end2
)
net stop wuauserv
echo 检查 wuauserv 服务状态。
sc query wuauserv | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto wuauserv
)
goto loop3

:end2
cls
echo.
echo 由于“ Windows Update”(wuauserv)服务无法停止,因此无法重置 Windows Update。请重新启动计算机,然后重试。
echo.
pause
goto Start



:loop3
set app=0

:appidsvc
set /a app=%app%+1
if %app% equ 3 (
   goto end3
)
net stop appidsvc
echo 检查 appidsvc 服务状态。
sc query appidsvc | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto appidsvc
)
goto loop4

:end3
cls
echo.
echo 由于“应用程序身份”(appidsvc)服务无法停止,因此无法重置 Windows Update。请重新启动计算机,然后重试。
echo.
pause
goto Start


:loop4
set c=0

:cryptsvc
set /a c=%c%+1
if %c% equ 3 (
   goto end4
)
net stop cryptsvc
echo 检查 cryptsvc 服务状态。
sc query cryptsvc | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto cryptsvc
)
goto Reset

:end4
cls
echo.
echo 由于“加密服务”(cryptsvc)服务无法停止,因此无法重置 Windows Update。请重新启动计算机,然后重试。
echo.
pause
goto Start


:Reset
Ipconfig /flushdns
del /s /q /f "%ALLUSERSPROFILE%/Application Data/Microsoft/Network/Downloader/qmgr*.dat"
del /s /q /f "%ALLUSERSPROFILE%/Microsoft/Network/Downloader/qmgr*.dat"
del /s /q /f "%SYSTEMROOT%/Logs/WindowsUpdate/*"


if exist "%SYSTEMROOT%/winsxs/pending.xml.bak" del /s /q /f "%SYSTEMROOT%/winsxs/pending.xml.bak"
if exist "%SYSTEMROOT%/winsxs/pending.xml" (
    takeown /f "%SYSTEMROOT%/winsxs/pending.xml"
    attrib -r -s -h /s /d "%SYSTEMROOT%/winsxs/pending.xml"
    ren "%SYSTEMROOT%/winsxs/pending.xml" pending.xml.bak
)
 
if exist "%SYSTEMROOT%/SoftwareDistribution.bak" rmdir /s /q "%SYSTEMROOT%/SoftwareDistribution.bak"
if exist "%SYSTEMROOT%/SoftwareDistribution" (
    attrib -r -s -h /s /d "%SYSTEMROOT%/SoftwareDistribution"
    ren "%SYSTEMROOT%/SoftwareDistribution" SoftwareDistribution.bak
)
 
if exist "%SYSTEMROOT%/system32/Catroot2.bak" rmdir /s /q "%SYSTEMROOT%/system32/Catroot2.bak"
if exist "%SYSTEMROOT%/system32/Catroot2" (
    attrib -r -s -h /s /d "%SYSTEMROOT%/system32/Catroot2"
    ren "%SYSTEMROOT%/system32/Catroot2" Catroot2.bak
)
 

:: 重置 Windows 更新策略
reg delete "HKCU/SOFTWARE/Policies/Microsoft/Windows/WindowsUpdate" /f
reg delete "HKCU/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/WindowsUpdate" /f
reg delete "HKLM/SOFTWARE/Policies/Microsoft/Windows/WindowsUpdate" /f
reg delete "HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/WindowsUpdate" /f
gpupdate /force


:: 将 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)

:: 重新注册 BITS 文件和 Windows Update 文件
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
regsvr32.exe /s wudriver.dll
netsh winsock reset
netsh winsock reset proxy

:: 将启动类型设置为自动
sc config wuauserv start= auto
sc config bits start= auto
sc config DcomLaunch start= auto

:Start
net start bits
net start wuauserv
net start appidsvc
net start cryptsvc

:: 重新启动计算机
cls
echo 需要重新启动计算机才能完成 Windows Update 重置。
echo.
echo 在重新启动计算机之前,请保存并关闭现在打开的所有内容。
echo.
pause
echo.
echo.
echo.
echo *** 立即重新启动计算机 ***
echo.
pause
shutdown /r /f /t 0

通过以上方法我们就可以在 Windows 10 中重置 Windows Update 啦。

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/141546.html

(0)
上一篇 2021年9月6日
下一篇 2021年9月6日

相关推荐

发表回复

登录后才能评论