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

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

精简脚本,在不删除服务的情况下阻止自动更新:

【已解决】【V2版本】如何使用脚本关闭Win10自动更新服务并阻止其自动启动?

【已解决】【V3版本】如何使用脚本关闭Win10自动更新服务并阻止其自动启动?

升级说明:

V1.1和V1.0版本不一样的地方是,V1.1版本是删除"usosvc"服务,而V1.0版本是删除"wuauserv"服务,由于"wuauserv"同时也提供了应用商店等其他程序的更新服务,因此删除后会导致应用商店等其他程序无法更新,使用V1.1版本则无此问题,因为V1.1版本删除的服务"usosvc"不影响其它程序,仅对Windows更新程序起作用;

前言:

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

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

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

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

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

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

1.备份注册表;

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

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

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

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

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

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

2.删除usosvc服务;

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

输入以下内容禁用Windows Update:

sc.exe stop usosvc

sc.exe delete usosvc

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

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

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

3.恢复usosvc服务;

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

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

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

sc.exe create usosvc binpath="c:\windows\system32\svchost.exe -k netsvcs -p -s UsoSvc" type=share start=auto error=normal tag=no depend=rpcss displayname="更新 Orchestrator 服务"

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

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

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

完了以后回到PowerShell窗口.

输入:

sc.exe start usosvc

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

等会儿再输入:

sc.exe query usosvc

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

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

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

1.保存文件;

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

' 管理Win10自动更新.vbs.
' 20210613 v1.1 补充了-s参数(无实际作用,仅保证完整性);
' 20210322 v1.1 为消除副作用,不再禁用wuauserv,改为禁用usosvc;
' 20190410 v1.0 增加了自动提权代码;
' 20190405 v1.0 初始版本,实现了基本功能;
' 使用说明 https://blog.csdn.net/milaoshu1020/article/details/89045265
Const usosvc_reg = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usosvc"
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. 备份usosvc服务的注册表信息;" & vbcrlf & _
						"2. 删除usosvc服务(将禁止Win10自动更新);" & vbcrlf & _
						"3. 恢复usosvc服务(将恢复Win10自动更新);" & vbcrlf & _
						vbcrlf & _
						"请输入序号:",,"1")
		Select Case ret
		Case "1"
			retnum = shell.run("regedit.exe /s /e """ & userregpath & """ """ & usosvc_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 usosvc",0,True)
			retnum = shell.run("sc.exe delete usosvc",0,True)
			If retnum = 0 Then
				msgbox "已删除usosvc服务!已禁止Win10自动更新!",vbexclamation
			Else
				msgbox "删除usosvc服务失败!'sc.exe'返回代码:" & retnum,vbcritical
			End If
			Exit Do
		Case "3"
			If fso.fileexists(userregpath) Then
				retnum = shell.run("sc.exe create usosvc binpath= ""c:\windows\system32\svchost.exe -k netsvcs -p -s UsoSvc"" type= share " & _
						"start= auto error= normal tag= no depend= rpcss displayname= ""更新 Orchestrator 服务""",0,True)
				If retnum <> 0 Then
					msgbox "恢复usosvc服务失败!'sc.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
				retnum = shell.run("regedit.exe /s """ & userregpath & """",0,True)
				If retnum <> 0 Then
					msgbox "恢复usosvc服务失败!'regedit.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
			ElseIf fso.fileexists(defaultregpath) Then
				retnum = shell.run("sc.exe create usosvc binpath= ""c:\windows\system32\svchost.exe -k netsvcs -p -s UsoSvc"" type= share " & _
						"start= auto error= normal tag= no depend= rpcss displayname= ""更新 Orchestrator 服务""",0,True)
				If retnum <> 0 Then
					msgbox "恢复usosvc服务失败!'sc.exe'返回代码:" & retnum,vbcritical
					Exit Do
				End If
				retnum = shell.run("regedit.exe /s """ & defaultregpath & """",0,True)
				If retnum <> 0 Then
					msgbox "恢复usosvc服务失败!'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 usosvc",0,True)
			If retnum <> 0 Then
				msgbox "启动usosvc服务失败!'sc.exe'返回代码:" & retnum,vbcritical
				Exit Do
			End If
			
			msgbox "成功恢复usosvc服务!成功恢复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\UsoSvc]
"DelayedAutoStart"=dword:00000001
"DependOnService"=hex(7):72,00,70,00,63,00,73,00,73,00,00,00,00,00
"Description"="@%systemroot%\\system32\\usosvc.dll,-102"
"DisplayName"="@%systemroot%\\system32\\usosvc.dll,-101"
"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,c0,d4,01,00,01,00,00,00,e0,93,04,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"
"PreshutdownTimeout"=dword:0036ee80
"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
"Type"=dword:00000020

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsoSvc\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,\
  75,00,73,00,6f,00,73,00,76,00,63,00,2e,00,64,00,6c,00,6c,00,00,00
"ServiceDllUnloadOnStop"=dword:00000001
"ServiceMain"="ServiceMain"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsoSvc\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

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

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

百度网盘:

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

其中"管理Win10自动更新v1.1.vbs"文件是开源的脚本文件,功能是备份/删除/恢复usosvc服务,以禁用/恢复Windows自动升级的功能;

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

2.启动脚本;

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

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

按照提示操作即可.

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

精简脚本,在不删除服务的情况下阻止自动更新:

【已解决】【V2版本】如何使用脚本关闭Win10自动更新服务并阻止其自动启动?

【已解决】【V3版本】如何使用脚本关闭Win10自动更新服务并阻止其自动启动?

 

FAQ:

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

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

 

你可能感兴趣的:(VBS,关闭自动更新,已解决,恢复,彻底关闭)