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"上點擊鼠標右鍵,選擇"導出":

選擇路徑並保存文件(記住文件完整路徑,一會兒恢復的時候要用到):

2.刪除wuauserv服務;
此操作很簡單,在"開始"按鈕上點擊右鍵,選擇"Windows PowerShell (管理員)(A)";

輸入以下內容禁用Windows Update:

sc.exe stop wuauserv

sc.exe delete wuauserv

此時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"

這還不夠,還需要找到第1步保存的註冊表文件,雙擊導入reg文件.

完了以後回到PowerShell窗口.

輸入:

sc.exe start wuauserv

等會兒再輸入:

sc.exe query wuauserv

此時服務已經恢復成功,並且成功啓動了.

第二部分 使用腳本自動備份刪除及恢復wuauserv服務.
1.保存文件;
先上腳本(文件名"管理Win10自動更新.vbs"):

' 管理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://download.csdn.net/download/u013862444/11258651

其中vbs文件是開源的腳本文件,功能是備份/刪除/恢復wuauserv服務,以禁用/恢復Windows自動升級的功能;

reg文件是標準的註冊表文件,用於在沒有備份的情況下恢復wuauserv服務的註冊表結構.

2.啓動腳本;
雙擊運行腳本,顯示對話框:

按照提示操作即可.

FAQ:
Q:恢復成功,但是"wuauserv"服務無法啓動,怎麼辦?

A:可以打開註冊表"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv"找到"WOW64"數據項,刪除即可;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章