Windows 一键设置命令(高风险)
这套命令用于一次性修改多项 Windows 安全和兼容性设置。它可能解决驱动无法加载、程序被拦截或虚拟化冲突,但也会明显降低系统保护。
高风险操作
命令会关闭或修改 Defender 实时保护、云保护、SmartScreen、UAC、DEP、CFG、HVCI、虚拟化、快速启动、SMB 签名要求和易受攻击驱动程序阻止列表,还会停止 Valorant Vanguard 服务。
不建议在办公电脑、存有重要资料的电脑或不了解恢复方法的电脑上执行。
执行前准备
执行前先完成下面几项:
- 保存正在处理的文件,关闭游戏和其他软件。
- 按 Win + S 搜索“创建还原点”,为系统盘创建一个还原点。
- 确认自己使用的是管理员账号,并准备好在失败时恢复系统。
- 如果电脑启用了 BitLocker,请先保存恢复密钥。
注意
Windows 的篡改防护、版本差异或公司策略可能让部分命令报错。出现红字不代表所有设置都失败,但也不能直接认为已经全部生效。
执行一键设置
右键点击 Windows 开始菜单,打开 终端管理员 或 Windows PowerShell(管理员)。复制下面的完整代码,粘贴到管理员窗口中,然后按回车。
Set-MpPreference -DisableRealtimeMonitoring $true; Set-MpPreference -MAPSReporting 0; reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy" /v "VerifiedAndReputablePolicyState" /t REG_DWORD /d 0 /f; Set-SmbClientConfiguration -RequireSecuritySignature $false -Force; Set-ProcessMitigation -System -Disable CFG; Set-ProcessMitigation -System -Disable DEP; Set-ProcessMitigation -System -Disable EmulateAtlThunks; Set-ProcessMitigation -System -Disable ForceRelocateImages; Set-ProcessMitigation -System -Disable BottomUp; Set-ProcessMitigation -System -Disable HighEntropy; Set-ProcessMitigation -System -Disable SEHOP; Set-ProcessMitigation -System -Disable StrictHandle; Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Windows Defender Exploit Guard\Network Protection" -Name "EnableNetworkProtection" -Value 0 -Force; Set-MpPreference -DisableBlockAtFirstSeen $true; Set-MpPreference -DisableIOAVProtection $true; Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableSmartScreen" -Value 0; bcdedit /set hypervisorlaunchtype off; reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v "Enabled" /t REG_DWORD /d 0 /f; reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Config" /v "VulnerableDriverBlocklistEnable" /t REG_DWORD /d 0 /f; Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 0; reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t REG_DWORD /d 0 /f; reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /t REG_DWORD /d 0 /f; Set-ItemProperty -Path "HKCU:\Software\Microsoft\Edge\SmartScreenEnabled" -Name "SmartScreenEnabled" -Value 0 -Type DWord; Set-ItemProperty -Path "HKCU:\Software\Microsoft\Edge\SmartScreenPuaEnabled" -Name "SmartScreenPuaEnabled" -Value 0 -Type DWord; reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "SmartScreenEnabled" /t REG_DWORD /d 0 /f; reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "SmartScreenPuaEnabled" /t REG_DWORD /d 0 /f; reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "PreventSmartScreenPromptOverride" /t REG_DWORD /d 0 /f; bcdedit /set hypervisorlaunchtype off; Start-Process powershell -ArgumentList "-Command Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters' -Name Type -Value NoSync; powercfg -h off
; Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters' -Name Type -Value NTP; Restart-Service w32time" -Verb RunAs
; if ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name -match '[\u4e00-\u9fa5\uff00-\uffef]') { "系统用户名含中文,部分菜单可能出现问题" } else { "" }; cmd /c "reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CI\Config /v VulnerableDriverBlocklistEnable /t REG_DWORD /d 0 /f && bcdedit /set hypervisorlaunchtype off"; if ((Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecureBoot\State").UEFISecureBootEnabled -eq 0) { "电脑为传统 BIOS 方案,部分内核菜单可能无法使用" } elseif ((Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecureBoot\State").UEFISecureBootEnabled -eq 1) { "" }; sc.exe stop vgk; sc.exe stop vgc; Write-Host "已完成所有禁用/检查方案" -ForegroundColor Red
命令运行结束后关闭终端,保存其他工作,然后重启电脑。Edge 的下载检查需要关闭并重新打开浏览器后才会刷新。
命令修改了什么
| 项目 | 影响 |
|---|---|
| Defender 与网络保护 | 降低实时扫描、下载扫描和云端拦截能力 |
| SmartScreen 与 UAC | 减少程序运行和管理员提权提示 |
| DEP、CFG、SEHOP 等缓解措施 | 降低对内存攻击和异常行为的防护 |
| HVCI、虚拟化与驱动阻止列表 | 允许部分旧驱动加载,但增加内核风险 |
| SMB 安全签名 | 降低部分局域网连接的验证要求 |
| 快速启动 | 改为完整关机,下一次开机时间可能变长 |
| Vanguard 服务 | Valorant 等依赖 Vanguard 的程序可能无法启动 |
恢复系统保护
不再需要这些兼容性设置时,使用管理员 PowerShell 执行下面的恢复命令。
Set-MpPreference -DisableRealtimeMonitoring $false
Set-MpPreference -MAPSReporting 2
Set-MpPreference -DisableBlockAtFirstSeen $false
Set-MpPreference -DisableIOAVProtection $false
Set-MpPreference -EnableNetworkProtection Enabled
Set-SmbClientConfiguration -RequireSecuritySignature $true -Force
Set-ProcessMitigation -System -Reset
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v "EnableSmartScreen" /t REG_DWORD /d 1 /f
bcdedit /set hypervisorlaunchtype auto
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v "Enabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Config" /v "VulnerableDriverBlocklistEnable" /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /t REG_DWORD /d 5 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "SmartScreenEnabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "SmartScreenPuaEnabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "PreventSmartScreenPromptOverride" /t REG_DWORD /d 1 /f
powercfg -h on
sc.exe start vgk
sc.exe start vgc
Write-Host "恢复命令已执行,请重启电脑后检查 Windows 安全中心" -ForegroundColor Green
恢复命令不是系统快照
恢复命令只能尽量改回对应设置。智能应用控制关闭后可能无法通过命令重新开启;如果 Windows 安全中心仍显示异常,请使用执行前创建的还原点,必要时重置或重新安装 Windows。
重启后检查 Windows 安全中心、UAC、内核隔离、Edge SmartScreen 和需要 Vanguard 的游戏,确认功能已经恢复。