标题: 关闭Win10/Win11的自动更新 作者: xiongshaojun 小码哥 swani13 创建: 2023-07-16 15:05 更新: 2023-07-24 20:26 链接: https://scz.617.cn/windows/202307161505.txt https://www.52pojie.cn/thread-1809122-1-1.html Win10的强制自动更新对许多群体不友好,搞网络安全的就不说了,搓火、辛酸。不 少人想变「强制自动更新」为「按需手动更新」,懂行的那是八仙过海、各显神通, 但过去我看到的方案都不尽人意。 最近在「吾爱破解」上看到一个变相关闭Win10/Win11自动更新的方案,可能是副作 用最小、最易实施的方案。 将如下内容存成"DisableAutoUpdate.reg",双击导入注册表即可。 -------------------------------------------------------------------------- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings] "FlightSettingsMaxPauseDays"=dword:1fffffff "PauseFeatureUpdatesStartTime"="2023-07-18T09:02:26Z" "PauseFeatureUpdatesEndTime"="2123-08-22T09:02:26Z" "PauseQualityUpdatesStartTime"="2023-07-18T09:02:26Z" "PauseQualityUpdatesEndTime"="2123-08-22T09:02:26Z" "PauseUpdatesExpiryTime"="2123-08-22T09:02:26Z" -------------------------------------------------------------------------- 可用如下命令确认注册表项设置成功 reg.exe query "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /s 还能看到两个有意思的键值,未深究: IsExpedited REG_DWORD 0x0 InsiderProgramEnabled REG_DWORD 0x0 如欲恢复自动更新,将如下内容存成"EnableAutoUpdate.reg",双击导入。 -------------------------------------------------------------------------- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings] "FlightSettingsMaxPauseDays"=- "PauseFeatureUpdatesStartTime"=- "PauseFeatureUpdatesEndTime"=- "PauseQualityUpdatesStartTime"=- "PauseQualityUpdatesEndTime"=- "PauseUpdatesExpiryTime"=- -------------------------------------------------------------------------- Diable时普通用户即可,Enable时若失败,就换管理员权限。非专业人员看到此处, 就可以了。 后面是一些逆向工程讨论。 52pojie帖子里有个"PauseUpdatesStartTime",该键值可能是想当然弄出来的,在逆 向工程中并未发现相应代码。 正常情况下,非LTSB版Win10可以暂停自动更新35天,该值在MusUpdateHandlers.dll 的PauseUpdatesUtility::GetMaxPauseQualityPeriodInDays()中固化。 Settings->Update & Security->Windows Update->Pause updates for 7 days 此处可以点击5次,也就是35天。该限制受注册表项FlightSettingsMaxPauseDays影 响,缺省没有FlightSettingsMaxPauseDays,此时使用缺省值35天。通过设置该键值, 可将暂停自动更新的天数上限推至极大,比如我将之设为0x1fffffff。一旦上限极大, 即可不停地点击"Pause updates for 7 days",不再因到达阈值而变灰。这是32位有 符号整数,理论上最大可设成0x7fffffff,但担心有加法上溢,保守起见,设成 0x1fffffff。 有两个StartTime,分别对应功能更新、质量更新,后者一般包含安全补丁。 StartTime就是你第一次点击"Pause updates for 7 days"的起始时间。 有两个EndTime,分别与前两个StartTime对应。正常情况下,EndTime-StarTime不会 超过35天。前例差值是100年,有生之年都不会再自动更新。 正常情况下,PauseUpdatesExpiryTime应与两个EndTime保持一致。也就是说,有两 个起始时间、三个结束时间。 接下来是一些具体的逆向工程活动。 用Process Monitor监控"Settings->Update & Security->Windows Update",在其中 搜索相应键值的读取操作,命中后查看PID及调用栈回溯。 PauseFeatureUpdatesEndTime 7 KERNELBASE.dll RegGetValueW + 0x254 0x7ffe13e92fe4 C:\Windows\System32\KERNELBASE.dll 8 UpdatePolicy.dll PolicyHelpers::ReadPolicyString + 0xd3 0x7ffe02efa0cf c:\windows\system32\UpdatePolicy.dll 9 UpdatePolicy.dll PolicyHelpers::ReadPolicyRegistry + 0x4c 0x7ffe02efa478 c:\windows\system32\UpdatePolicy.dll 10 UpdatePolicy.dll EnterprisePolicyReader::ReadPolicyWithFallbackInternal + 0x2a0 0x7ffe02eeea4c c:\windows\system32\UpdatePolicy.dll 11 UpdatePolicy.dll EnterprisePolicyReader::ReadPolicyWithFallback + 0x105 0x7ffe02eee755 c:\windows\system32\UpdatePolicy.dll 12 WaaSAssessment.dll DeviceAttributes::GetFeatureUpdatePauseStatus + 0x64 0x7ffdfea9ca14 C:\Windows\System32\WaaSAssessment.dll 13 WaaSAssessment.dll AssessmentCore::GetFeatureUpdateAssessmentReason + 0x142 0x7ffdfea97432 C:\Windows\System32\WaaSAssessment.dll 14 WaaSAssessment.dll AssessmentCore::GetAssessmentReason + 0x74 0x7ffdfea97794 C:\Windows\System32\WaaSAssessment.dll 15 WaaSAssessment.dll AssessmentCore::IsCurrent + 0x84 0x7ffdfea97834 C:\Windows\System32\WaaSAssessment.dll 16 WaaSAssessment.dll AssessmentCore::PerformAssessment + 0xf2 0x7ffdfea96de2 C:\Windows\System32\WaaSAssessment.dll 17 WaaSAssessment.dll AssessmentCore::GetOSUpdateAssessmentInternal + 0xf5 0x7ffdfea96bd5 C:\Windows\System32\WaaSAssessment.dll 18 WaaSAssessment.dll AssessmentCore::GetOSUpdateAssessment + 0x6d 0x7ffdfea96a6d C:\Windows\System32\WaaSAssessment.dll 19 usosvc.dll ::operator() + 0x204 0x7ffdf74c0b78 c:\windows\system32\usosvc.dll 20 usosvc.dll UxUpdateManager::GetIsWaaSOutOfDate + 0x8a 0x7ffdf74c08aa c:\windows\system32\usosvc.dll 21 RPCRT4.dll Invoke + 0x73 0x7ffe1614b4b3 C:\Windows\System32\RPCRT4.dll 22 RPCRT4.dll Ndr64StubWorker + 0xb0b 0x7ffe161ae77b C:\Windows\System32\RPCRT4.dll 23 RPCRT4.dll NdrStubCall3 + 0xc9 0x7ffe160ed479 C:\Windows\System32\RPCRT4.dll PID是5484,查看对应服务: tasklist /svc /fi "pid eq 5484" "Z:\Green\Windows Kits\10\x64\Debuggers\x64\tlist.exe" -s | findstr Svcs | findstr 5484 sc queryex UsoSvc sc qc UsoSvc 这是"Update Orchestrator Service (UsoSvc)"服务。在管理员级cmd中执行 net use Z: "\\vmware-host\Shared Folders" "Z:\Green\Windows Kits\10\x64\Debuggers\x64\cdb.exe" -noinh -snul -hd -o -p 5484 .prompt_allow +reg +ea +dis > lm m UpdatePolicy start end module name 00007ffe`02ee0000 00007ffe`02f1d000 UpdatePolicy 用IDA反汇编UpdatePolicy.dll,Rebase后直奔调用栈回溯中的地址,查看相应代码。 PauseUpdatesExpiryTime: 6 KernelBase.dll RegQueryValueExW + 0x108 0x7ffe13e93808 C:\Windows\System32\KernelBase.dll 7 MusUpdateHandlers.dll RegistryManager::HKLMValueExists + 0x16a 0x7ffded14a90a C:\Windows\System32\MusUpdateHandlers.dll 8 MusUpdateHandlers.dll PauseUpdatesUtility::GetPauseUpdatesExpiryTimeRegValue + 0x62 0x7ffded156ad6 C:\Windows\System32\MusUpdateHandlers.dll 9 MusUpdateHandlers.dll PauseUpdatesUtility::AreUpdatesPaused + 0x26 0x7ffded1567fa C:\Windows\System32\MusUpdateHandlers.dll 10 MusUpdateHandlers.dll SystemSettings::Update::CMusOrchModel::SaveInsiderProgramStatus + 0xf 0x7ffded10fa4f C:\Windows\System32\MusUpdateHandlers.dll 11 MusUpdateHandlers.dll SystemSettings::Update::CMusOrchModel::SingletonInitialize + 0x55a 0x7ffded107502 C:\Windows\System32\MusUpdateHandlers.dll 12 MusUpdateHandlers.dll SystemSettings::Update::CMusOrchModel::OnSingletonInit + 0x1a 0x7ffded107f0a C:\Windows\System32\MusUpdateHandlers.dll 13 MusUpdateHandlers.dll SystemSettings::DataModel::CSingletonHelper::_Initialization + 0x89 0x7ffded0b3f01 C:\Windows\System32\MusUpdateHandlers.dll 14 MusUpdateHandlers.dll SystemSettings::DataModel::CSingletonHelper::s_InitializationThread + 0x9 0x7ffded0b4039 C:\Windows\System32\MusUpdateHandlers.dll 15 SHCore.dll _WrapperThreadProc + 0xe9 0x7ffe15e2bf69 C:\Windows\System32\SHCore.dll FlightSettingsMaxPauseDays: 6 KernelBase.dll RegQueryValueExW + 0x108 0x7ffe13e93808 C:\Windows\System32\KernelBase.dll 7 MusUpdateHandlers.dll RegistryManager::HKLMValueExists + 0x16a 0x7ffded14a90a C:\Windows\System32\MusUpdateHandlers.dll 8 MusUpdateHandlers.dll PauseUpdatesUtility::GetMaxPauseQualityPeriodInDays + 0x40 0x7ffded156970 C:\Windows\System32\MusUpdateHandlers.dll 9 MusUpdateHandlers.dll SystemSettings::Update::CMusUpdatePauseUpdate2::InitializeState + 0x1ce 0x7ffded0dc61e C:\Windows\System32\MusUpdateHandlers.dll 10 MusUpdateHandlers.dll ::operator() + 0x122 0x7ffded0c6b72 C:\Windows\System32\MusUpdateHandlers.dll 11 MusUpdateHandlers.dll std::thread::_Invoke >,0> + 0xe 0x7ffded0c81ee C:\Windows\System32\MusUpdateHandlers.dll 12 ucrtbase.dll thread_start + 0x42 0x7ffe14181bb2 C:\Windows\System32\ucrtbase.dll PID是6732,对应下列进程: "C:\Windows\ImmersiveControlPanel\SystemSettings.exe" -ServerName:microsoft.windows.immersivecontrolpanel 直接在cmd中执行上述命令,会失败,不信可以试试。 "Z:\Green\Windows Kits\10\x64\Debuggers\x64\cdb.exe" -noinh -snul -hd -o -p 6732 .prompt_allow +reg +ea +dis > lm m MusUpdateHandlers start end module name 00007ffd`ed0a0000 00007ffd`ed1c2000 MusUpdateHandlers 用IDA反汇编MusUpdateHandlers.dll并Rebase。 隐式FlightSettingsMaxPauseDays设置阻止通过UI无限暂停,但无它也无所谓。可先 手动暂停35天,以生成StartTime、EndTime、ExpiryTime等键值,然后直接修改结束 时间。 reg.exe add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "PauseFeatureUpdatesEndTime" /t REG_SZ /d "2123-08-22T09:02:26Z" /f reg.exe add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "PauseQualityUpdatesEndTime" /t REG_SZ /d "2123-08-22T09:02:26Z" /f reg.exe add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "PauseUpdatesExpiryTime" /t REG_SZ /d "2123-08-22T09:02:26Z" /f reg.exe query "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /s $ python3 -c "import datetime;print(datetime.date(2123,8,22)-datetime.date(2023,7,18))" 36559 days, 0:00:00 网友swani13提及另一个邪门方案。先timedate.cpl修改系统时间到2099.12.31,这 是UI可调的最晚时间,暂时关闭NTP同步,或者干脆断网,然后5次点击暂停更新,最 后恢复正常系统时间。此法纯UI操作,实际就是设置超大结束时间。Windows毕竟不 是那些需要反破解的小软件,未对各种时间戳做一致性、合理性检查,对结束时间只 做简单比较,这就给人以可乘之机。 在UI中"Resume updates",会自动删除StartTime、EndTime、ExpiryTime等键值,但 不会自动删除或更改FlightSettingsMaxPauseDays,这是后者的优势。可以单设后者 reg.exe query "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "FlightSettingsMaxPauseDays" reg.exe add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "FlightSettingsMaxPauseDays" /t REG_DWORD /d 0x1fffffff /f reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "FlightSettingsMaxPauseDays" /f 建议专业人员只设置超大"FlightSettingsMaxPauseDays",便于手动控制。该键值有 点意思,普通用户可以创建、修改,但不能删除,只有管理员可以删除。 LTSB版Win10不支持暂停更新,下列命令无输出: Z:\Green\sysinternals\strings.exe -u C:\Windows\System32\MusUpdateHandlers.dll | findstr Pause // ////////////////////////////////////////////////////////////////////////// // zz转述zyh的方案,说是禁用自动更新的服务"Windows Update (wuauserv)"可达目的, 我未实测。 sc config wuauserv start= disabled sc stop wuauserv 该服务设的是手动启动,但有触发器,实际是任务计划程序: -------------------------------------------------------------------------- taskschd.msc Task Scheduler (Local) Task Scheduler Library Microsoft Windows WindowsUpdate -------------------------------------------------------------------------- $ schtasks /query /tn "\Microsoft\Windows\WindowsUpdate\Scheduled Start" Folder: \Microsoft\Windows\WindowsUpdate TaskName Next Run Time Status ======================================== ====================== =============== Scheduled Start 2023/7/21 14:24:30 Ready 正常情况下,该任务每天执行一次,将下一次执行安排在约24小时后。可以禁用该任 务。在管理员级cmd中执行 schtasks /change /tn "\Microsoft\Windows\WindowsUpdate\Scheduled Start" /disable schtasks /change /tn "\Microsoft\Windows\WindowsUpdate\Scheduled Start" /enable 此法可能适用于LTSB版Win10,亦未实测。 // ////////////////////////////////////////////////////////////////////////// // Windows Update Blocker v1.8 - [2023-06-10] https://www.sordum.org/9470/windows-update-blocker-v1-8/ https://www.sordum.org/downloads/?st-windows-update-blocker https://www.sordum.org/files/download/windows-update-blocker/Wub_v1.8.zip zz提到上述GUI工具,应该就是禁用wuauserv服务之类的,对于专业人员没啥意义, 啥都不懂的小白倒是可以试试。 // ////////////////////////////////////////////////////////////////////////// // 后面各种方案,只记录、不评价。 -------------------------------------------------------------------------- gpedit.msc Local Computer Policy Computer Configuration Administrative Templates Windows Components Windows Update Configure Automatic Updates Enabled 2 - Notify for download and auto install Specify intranet Microsoft update serwice location Enabled Set the intranet update service for detecting updates https://127.0.0.1 Set the intranet statistics server https://127.0.0.1 -------------------------------------------------------------------------- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] "WUServer"="https://127.0.0.1" "WUStatusServer"="https://127.0.0.1" "SetProxyBehaviorForUpdateDetection"=dword:00000000 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU] "NoAutoUpdate"=dword:00000001 "AUOptions"=dword:00000002 "UseWUServer"=dword:00000001 -------------------------------------------------------------------------- reg.exe query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /s reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "WUServer" /t REG_SZ /d "https://127.0.0.1" /f reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "WUStatusServer" /t REG_SZ /d "https://127.0.0.1" /f reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "UseWUServer" /t REG_DWORD /d 1 /f reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" /t REG_DWORD /d 2 /f reg.exe query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" /f reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /t REG_DWORD /d 1 /f