【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?

更新失败的问题我已经参考这篇文章解决了: 【亲测管用】Windows10无法完成更新,正在撤销更改怎么办? 

精简脚本,在不删除服务的情况下阻止自动更新: 【亲测管用】如何使用脚本关闭Win10自动更新服务并阻止其自动启动?

如何关闭Windows10的自动更新真的是个大难题.

当你遇到Windows更新包安装失败,却又被强制每天重新安装并且失败(安装失败有的时候得重启好几次),望着一遍又一遍重启的计算机,你是不是有些抓狂?

这里给了你一个解决办法,那就是彻底删除自动更新服务(wuauserv)来阻止自动更新.

首先我们讲如何备份相关注册表,手动删除这个服务,并且在必要的时候如何手动恢复这个服务.

然后我会给出一个激动人心的脚本,自动完成"备份/删除/恢复wuauserv服务"的操作.

第一部分 手动备份,删除及恢复wuauserv服务.

1.备份注册表;

wuauserv服务的大部分信息都存在"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv"路径中,所以要备份这个子键,然后在需要的时候会用到.

方法是按Win+R打开运行窗口,或者按Win+Q打开搜索窗口,输入regedit并点击回车(Enter);

找到路径"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv",在"wuauserv"上点击鼠标右键,选择"导出":

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第1张图片

选择路径并保存文件(记住文件完整路径,一会儿恢复的时候要用到):

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第2张图片

2.删除wuauserv服务;

此操作很简单,在"开始"按钮上点击右键,选择"Windows PowerShell (管理员)(A)";

输入以下内容禁用Windows Update:

sc.exe stop wuauserv

sc.exe delete wuauserv

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第3张图片

此时windows 10 已经不会再执行自动更新了......

如果想恢复使用自动更新,那就继续看......

3.恢复wuauserv服务;

恢复服务是相对难度比较高的操作,

在"开始"按钮上点击右键,选择"Windows PowerShell (管理员)(A)";

输入以下内容恢复wuauserv(Windows Update)服务:

sc.exe create wuauserv binpath="c:\windows\system32\svchost.exe -k netsvcs -p" type=share start=auto error=normal tag=no depend=rpcss displayname="Windows Update"

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第4张图片

 

这还不够,还需要找到第1步保存的注册表文件,双击导入reg文件.

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第5张图片

完了以后回到PowerShell窗口.

输入:

sc.exe start wuauserv

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第6张图片

等会儿再输入:

sc.exe query wuauserv

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第7张图片

此时服务已经恢复成功,并且成功启动了.

第二部分 使用脚本自动备份删除及恢复wuauserv服务.

1.保存文件;

先上脚本(文件名"管理Win10自动更新.vbs",保存编码"ANSI"):

' 管理Win10自动更新.vbs.
' 20190410 增加了自动提权代码;
' 20190405 初始版本,实现了基本功能;
' 使用说明 https://blog.csdn.net/milaoshu1020/article/details/89045265
Const wuauserv_reg = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv"
Set fso = createobject("scripting.filesystemobject")
Set shell = createobject("wscript.shell")
curdir = fso.getparentfoldername(wscript.scriptfullname)
userregpath = fso.buildpath(curdir,"user.reg")
defaultregpath = fso.buildpath(curdir,"default.reg")

If wscript.arguments.count = 0 Then
	Set sh = createobject("shell.application")
	sh.shellexecute wscript.fullname,"""" & wscript.scriptfullname & """ -admin",,"runas"
ElseIf wscript.arguments.count = 1 And wscript.arguments(0) = "-admin" Then
	run
Else
	msgbox "脚本启动参数错误!"
End If

Sub Run()
	Do
		ret = inputbox("1. 备份wuauserv服务的注册表信息;" & vbcrlf & _
						"2. 删除wuauserv服务(将禁止Win10自动更新);" & vbcrlf & _
						"3. 恢复wuauserv服务(将恢复Win10自动更新);" & vbcrlf & _
						vbcrlf & _
						"请输入序号:",,"1")
		Select Case ret
		Case "1"
			retnum = shell.run("regedit.exe /s /e """ & userregpath & """ """ & wuauserv_reg & """",0,True)
			If retnum = 0 Then
				msgbox "注册表备份完成!",vbinformation
			Else
				msgbox "注册表备份失败!'regedit.exe'返回代码:" & retnum,vbcritical
			End If
			Exit Do
		Case "2"
			retnum = shell.run("sc.exe stop wuauserv",0,True)
			retnum = shell.run("sc.exe delete wuauserv",0,True)
			If retnum = 0 Then
				msgbox "已删除wuauserv服务!已禁止Win10自动更新!",vbexclamation
			Else
				msgbox "删除wuauserv服务失败!'sc.exe'返回代码:" & retnum,vbcritical
			End If
			Exit Do
		Case "3"
			If fso.fileexists(userregpath) Then
				retnum = shell.run("sc.exe create wuauserv binpath= ""c:\windows\system32\svchost.exe -k netsvcs -p"" type= share " & _
						"start= auto error= normal tag= no depend= rpcss displayname= ""Windows Update""",0,True)
				If retnum <> 0 Then
					msgbox "恢复wuauserv服务失败!'sc.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
				retnum = shell.run("regedit.exe /s """ & userregpath & """",0,True)
				If retnum <> 0 Then
					msgbox "恢复wuauserv服务失败!'regedit.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
			ElseIf fso.fileexists(defaultregpath) Then
				retnum = shell.run("sc.exe create wuauserv binpath= ""c:\windows\system32\svchost.exe -k netsvcs -p"" type= share " & _
						"start= auto error= normal tag= no depend= rpcss displayname= ""Windows Update""",0,True)
				If retnum <> 0 Then
					msgbox "恢复wuauserv服务失败!'sc.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
				retnum = shell.run("regedit.exe /s """ & defaultregpath & """",0,True)
				If retnum <> 0 Then
					msgbox "恢复wuauserv服务失败!'regedit.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
			Else
				msgbox "未找到注册表文件(user.reg|default.reg)!恢复失败!",vbcritical
				Exit Do
			End If

			retnum = shell.run("sc.exe start wuauserv",0,True)
			If retnum <> 0 Then
				msgbox "启动wuauserv服务失败!'sc.exe'返回代码:" & retnum,vbcritical
				Exit Do
			End If
			
			msgbox "成功恢复wuauserv服务!成功恢复Win10自动更新!",vbexclamation
			Exit Do
		Case ""
			Exit Do
		Case Else
			msgbox "输入错误!请重新输入!",vbcritical
		End Select
	Loop
End Sub

再上注册表文件(文件名"default.reg"):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv]
"DependOnService"=hex(7):72,00,70,00,63,00,73,00,73,00,00,00,00,00
"Description"="@%systemroot%\\system32\\wuaueng.dll,-106"
"DisplayName"="@%systemroot%\\system32\\wuaueng.dll,-105"
"ErrorControl"=dword:00000001
"FailureActions"=hex:80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,14,00,00,\
  00,01,00,00,00,60,ea,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,\
  74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,\
  00,76,00,63,00,68,00,6f,00,73,00,74,00,2e,00,65,00,78,00,65,00,20,00,2d,00,\
  6b,00,20,00,6e,00,65,00,74,00,73,00,76,00,63,00,73,00,20,00,2d,00,70,00,00,\
  00
"ObjectName"="LocalSystem"
"RequiredPrivileges"=hex(7):53,00,65,00,41,00,75,00,64,00,69,00,74,00,50,00,72,\
  00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,43,00,72,00,\
  65,00,61,00,74,00,65,00,47,00,6c,00,6f,00,62,00,61,00,6c,00,50,00,72,00,69,\
  00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,43,00,72,00,65,00,\
  61,00,74,00,65,00,50,00,61,00,67,00,65,00,46,00,69,00,6c,00,65,00,50,00,72,\
  00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,54,00,63,00,\
  62,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,\
  00,41,00,73,00,73,00,69,00,67,00,6e,00,50,00,72,00,69,00,6d,00,61,00,72,00,\
  79,00,54,00,6f,00,6b,00,65,00,6e,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,\
  00,67,00,65,00,00,00,53,00,65,00,49,00,6d,00,70,00,65,00,72,00,73,00,6f,00,\
  6e,00,61,00,74,00,65,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,\
  00,00,00,53,00,65,00,49,00,6e,00,63,00,72,00,65,00,61,00,73,00,65,00,51,00,\
  75,00,6f,00,74,00,61,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,\
  00,00,00,53,00,65,00,53,00,68,00,75,00,74,00,64,00,6f,00,77,00,6e,00,50,00,\
  72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,44,00,65,\
  00,62,00,75,00,67,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,\
  00,00,53,00,65,00,42,00,61,00,63,00,6b,00,75,00,70,00,50,00,72,00,69,00,76,\
  00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,52,00,65,00,73,00,74,00,\
  6f,00,72,00,65,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,\
  00,53,00,65,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,50,00,72,00,\
  69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,54,00,61,00,6b,\
  00,65,00,4f,00,77,00,6e,00,65,00,72,00,73,00,68,00,69,00,70,00,50,00,72,00,\
  69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,4c,00,6f,00,61,\
  00,64,00,44,00,72,00,69,00,76,00,65,00,72,00,50,00,72,00,69,00,76,00,69,00,\
  6c,00,65,00,67,00,65,00,00,00,53,00,65,00,4d,00,61,00,6e,00,61,00,67,00,65,\
  00,56,00,6f,00,6c,00,75,00,6d,00,65,00,50,00,72,00,69,00,76,00,69,00,6c,00,\
  65,00,67,00,65,00,00,00,53,00,65,00,53,00,79,00,73,00,74,00,65,00,6d,00,45,\
  00,6e,00,76,00,69,00,72,00,6f,00,6e,00,6d,00,65,00,6e,00,74,00,50,00,72,00,\
  69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,43,00,72,00,65,\
  00,61,00,74,00,65,00,53,00,79,00,6d,00,62,00,6f,00,6c,00,69,00,63,00,4c,00,\
  69,00,6e,00,6b,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,\
  00,53,00,65,00,49,00,6e,00,63,00,72,00,65,00,61,00,73,00,65,00,42,00,61,00,\
  73,00,65,00,50,00,72,00,69,00,6f,00,72,00,69,00,74,00,79,00,50,00,72,00,69,\
  00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,00,00
"ServiceSidType"=dword:00000001
"Start"=dword:00000002
"SvcMemHardLimitInMB"=dword:000000f6
"SvcMemMidLimitInMB"=dword:000000a7
"SvcMemSoftLimitInMB"=dword:00000058
"Type"=dword:00000020

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv\Parameters]
"ServiceDll"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,\
  00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
  77,00,75,00,61,00,75,00,65,00,6e,00,67,00,2e,00,64,00,6c,00,6c,00,00,00
"ServiceDllUnloadOnStop"=dword:00000001
"ServiceMain"="WUServiceMain"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv\Security]
"Security"=hex:01,00,14,80,78,00,00,00,84,00,00,00,14,00,00,00,30,00,00,00,02,\
  00,1c,00,01,00,00,00,02,80,14,00,ff,00,0f,00,01,01,00,00,00,00,00,01,00,00,\
  00,00,02,00,48,00,03,00,00,00,00,00,14,00,9d,00,02,00,01,01,00,00,00,00,00,\
  05,0b,00,00,00,00,00,18,00,ff,01,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,\
  20,02,00,00,00,00,14,00,ff,01,0f,00,01,01,00,00,00,00,00,05,12,00,00,00,01,\
  01,00,00,00,00,00,05,12,00,00,00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv\TriggerInfo]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv\TriggerInfo\0]
"Type"=dword:00000005
"Action"=dword:00000001
"Guid"=hex:e6,ca,9f,65,db,5b,a9,4d,b1,ff,ca,2a,17,8d,46,e0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv\TriggerInfo\1]
"Type"=dword:00000005
"Action"=dword:00000001
"Guid"=hex:c8,46,fb,54,89,f0,4c,46,b1,fd,59,d1,b6,2c,3b,50

将这两个文件放到同一个目录下.

为了方便小白,在此提供脚本文件和默认注册表文件的下载地址:

百度网盘:

链接:https://pan.baidu.com/s/1MLPzqQZsaehfhzw5OC07xQ
提取码:8488 

其中vbs文件是开源的脚本文件,功能是备份/删除/恢复wuauserv服务,以禁用/恢复Windows自动升级的功能;

reg文件是标准的注册表文件,用于在没有备份的情况下恢复wuauserv服务的注册表结构.

2.启动脚本;

双击运行脚本,显示对话框:

【已解决】如何彻底关闭Win10的自动更新并且随时可以恢复?_第8张图片

按照提示操作即可.

FAQ:

Q:恢复成功,但是"wuauserv"服务无法启动,怎么办?

A:可以打开注册表"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv"找到"WOW64"数据项,删除即可;

 

你可能感兴趣的:(系统,Win10,服务)