在 Windows 中,部分组策略通过组策略编辑器(gpedit.msc
家庭版不存在)并不能直接进行配置
而完整的组策略实际存储于注册表中
因为一些原因,例如安装系统时使用了市面上的某些 PE,而这部分 PE 会对操作系统进行一系列的更改,包括但不限于禁用 UAC、系统更新、防火墙、安全中心等等
当然还有就是误操作或者忘记自己设置了某些策略导致系统出现问题
这时我们就需要还原组策略从而达到操作系统恢复正常的目的
参考来源:https://www.elevenforum.com/t/reset-all-local-group-policy-settings-to-default-in-windows-11.21587/
通过如下命令进行组策略对应注册项的清理(以下操作不包括本地安全策略,建议在操作前进行备份):
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies" /f
reg delete "HKCU\Software\Policies" /f
reg delete "HKLM\Software\Microsoft\Policies" /f
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /f
reg delete "HKLM\Software\Policies" /f
reg delete "HKLM\Software\WOW6432Node\Microsoft\Policies" /f
reg delete "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies" /f
reg delete "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /f
根据作者说明,需特别注意! 在删除 HKLM\Software\Microsoft\Windows\CurrentVersion\Policies
时会导致 Windows 设置 -> 应用程序 -> 启动 页面丢失,所以我在命令中移除了对这个项的删除
如果你仍然需要移除该项,请按照如下命令依次执行,必需全部执行:
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies" /f
:: 如下是对必要的键值恢复默认
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v SupportUwpStartupTasks /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableFullTrustStartupTasks /t REG_DWORD /d 2 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableUwpStartupTasks /t REG_DWORD /d 2 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v SupportFullTrustStartupTasks /t REG_DWORD /d 1 /f
最后移除相应的文件并执行更新组策略命令:
rd /s /q "%windir%\System32\GroupPolicy"
rd /s /q "%windir%\System32\GroupPolicyUsers"
mkdir "%windir%\System32\GroupPolicyUsers"
gpupdate /force
关于 gpupdate
,可参考官方:https://learn.microsoft.com/zh-cn/windows-server/administration/windows-commands/gpupdate
建议在恢复默认后重启系统