windows-defender-remover 实战指南:彻底移除 Windows Defender、安全中心与 VBS 等安全组件
windows-defender-remover 实战指南:彻底移除 Windows Defender、安全中心与 VBS 等安全组件
本篇技术指南围绕开源仓库 windows-defender-remover 的根目录 README(README.md)展开,完整讲解该工具在 Windows 8.x / Windows 10(全版本)/ Windows 11 上移除或禁用 Windows Defender、Windows 安全中心、VBS 虚拟化安全、SmartScreen、Windows Web 威胁服务等一系列安全组件的方式。读者将掌握三种运行入口(Release 可执行文件、git clone、源码压缩包)、交互式与命令行自动化两种操作模式,以及通过 $OEM$ + unattend.xml 制作"开箱即无 Defender"的定制 Windows ISO 的完整方法,并能借助仓库内 15 份注册表策略文件与 PowerShell 脚本理解每一步的底层原理。
项目定位与三个核心模块
windows-defender-remover 是一个面向 Windows 8.x、Windows 10(每一个版本)和 Windows 11 的 Defender 移除/禁用工具。仓库以三个子模块组织,根目录 README 在 "Project Modules" 一节中给出了它们的分工:
- ISO Maker:打造一个"从第一次启动起 Defender 即处于禁用状态"的定制 Windows ISO;
- Remove Defender Engine:移除杀毒引擎核心(防病毒服务、驱动、SmartScreen、SpyNet 遥测、计划任务与右键菜单);
- Remove Security App:移除 Windows 安全(Security)UI 与安全中心服务。
三者可以组合成"完整移除"链路:先由 Remove Defender Engine 拆掉杀毒后端,再由 Remove Security App 拆掉前端界面,最后用 ISO Maker 把整套方案固化进安装介质。
注意:Remove_Defender 模块在移除上述项目后,通常仍会保留 "Windows 安全" 应用界面,只是其中的防病毒保护已经失效/被禁用;若连应用界面一并移除,需配合 Remove_SecurityComp 模块使用(见 Remove_Defender/README.md)。
应用究竟做了什么:组件移除清单
根目录 README 用两个小节("Removing Security Components" 与 "Removing Antivirus Components")明确列出了脚本会移除/禁用的对象,这是评估工具影响面的第一手依据。
移除的安全组件(Security Components)
- Windows 安全中心支持:包括安全中心服务
wscsvc、Windows 安全服务(SgrmBroker、Sgrm 驱动),它们是运行 Windows 安全应用所必需的组件; - 虚拟化支持(VBS 相关):
- Hypervisor 启动项:用于解决虚拟化安全(VBS)无法禁用的问题;注意如果你之后使用 Hyper-V、WSL(Windows Subsystem for Linux)、WSA(Windows Subsystem for Android),VBS 会被自动重新启用;
- LUA:禁用文件虚拟化与用户账户控制(UAC),此后所有应用以管理员权限运行(官方同时注明这能修复一些旧应用的报错);
- Exploit Guard:针对漏洞利用防护;
- Windows Smart Control(Windows 智能应用控制);
- Tamper Protection(适用于 Windows 11 21H2 及更早版本);
- SecHealthUI:Windows 安全 UWP 应用;
- SmartScreen:阻止"无法识别"应用的过滤器;
- Pluton 支持与 Pluton 服务支持:即
PlutonHeci/PlutonHsp2相关服务(见下文 RemoveServices.reg); - 系统缓解(System Mitigations):
- "Services Mitigations"(对应 Svchost 缓解策略,官方提示可在 admx.help 上检索策略说明);
- Spectre 与 Meltdown 缓解(官方注明:在老款 Intel CPU 上可换取约 +30% 性能);
- 设置应用中"Windows 安全"分区:通过
SettingsPageVisibility策略隐藏。
移除的杀毒组件(Antivirus Components)
- Windows Defender 定义更新列表:禁用 Defender 的定义更新(因为杀毒本体已被移除);
- Windows Defender SpyNet 遥测:停止向 Microsoft 发送数据;
- 防病毒服务:阻止文件执行的杀毒主引擎;
- Windows Defender 杀毒过滤器与 rootkit 扫描驱动:文件系统过滤驱动与启动引导驱动;
- 杀毒扫描计划任务:禁用自动扫描与维护任务;
- Shell 关联(右键菜单):移除资源管理器右键菜单中的 "Scan with Windows Defender";
- 从 Windows 安全应用中隐藏"防病毒保护"分区。
快速开始:三种运行方式与前置条件
根目录 README 的 "Instructions" 一节给出了三种运行入口,同时在开头给出了一条重要建议:
[!NOTE] 在运行脚本之前强烈建议创建系统还原点(如果你不完全清楚自己在做什么)。
方式一:Release 打包脚本
- 从 Releases 页面下载打包好的脚本(打包为
.exe); - 以管理员身份运行该
.exe; - 按屏幕提示操作。
方式二:git clone 后直接运行
git clone https://gitcode.com/gh_mirrors/wi/windows-defender-remover
cd windows-defender-remover
Script_Run.bat
方式三:下载完整源码
- 从 Releases 页面下载最后一版的 Source Code(.zip);
- 解压到任意目录;
- 运行其中的
Script_Run.bat。
运行入口本身是仓库根目录的 Script_Run.bat。从源码结构看,脚本开头会先执行 net session 检查当前是否具有管理员权限,若没有则通过 powershell -Command "Start-Process '%~f0' -Verb RunAs" 重新以管理员身份拉起自身——这正是"必须以管理员运行"的自动化实现。
Script_Run.bat 交互菜单与自动化参数
交互式三选项
Script_Run.bat 顶部定义了当前脚本版本:@set defenderremoverver=13.0。启动后(在拥有管理员权限的前提下)会显示如下菜单:
Do you want to remove Windows Defender and alongside components? After this you'll need to reboot.
A backup and/or System Restore point is recommended.
[Y] Remove Windows Defender Antivirus + Windows Security App
[A] Remove Windows Defender Antivirus App (keeps Windows Security App, it will be back if you update)
[S] Remove Defender Files (if you removed antivirus first)
三个选项的分支逻辑(对应 Script_Run.bat 中的 :removedef / :removeantivirus / :removalfiles 标签):
- Y(removedef,完整移除):先执行
Powerrun powershell.exe -noprofile -executionpolicy bypass -file "RemoveSecHealthApp.ps1"移除 Windows 安全 UWP 应用;随后用FOR /R %%f IN (Remove_defender\*.reg) DO PowerRun.exe regedit.exe /s "%%f"静默合并Remove_Defender目录下全部.reg(并再以普通regedit.exe /s合并一次),再以同样方式合并Remove_SecurityComp\*.reg;等待 3 秒后执行shutdown /r /f /t 10自动重启。 - A(removeantivirus,仅移除杀毒):只合并
Remove_defender\*.reg,保留 Windows 安全应用(官方注明:更新后该应用可能回归),随后自动重启。 - S(removalfiles,移除残留文件):通过
PowerRun cmd.exe /k files_removal.bat调用 files_removal.bat。该批处理使用takeown /f ... /r /d y、icacls ... /grant administrators:F /t、rd /s /q ...依次删除四个目录:C:\ProgramData\Microsoft\Windows Defender、C:\Program Files\Windows Defender、C:\Program Files (x86)\Windows Defender、C:\Program Files\Windows Defender Advanced Threat Protection。此选项需在已执行过"先移除杀毒"的前提下使用。
命令行自动化
README 的 "Automation of the script" 一节说明,可以携带参数直接执行移除,无需交互:
# Removal
Defender.Remover.exe /r <# or /R #>
配合批处理入口时,Script_Run.bat 同样支持参数短路(IF "%1"=="y" GOTO :removedef、IF "%1"=="a" GOTO :removeantivirus),从源码结构可以推断 y/a 分别对应交互菜单中的 Y 与 A 分支。
底层实现剖析:注册表策略、服务删除与 AppX 移除
整个工具的核心动作在仓库内以"一份 .reg 文件一个职责"的方式组织,Remove_Defender 目录下共 15 份注册表文件,另有 Remove_SecurityComp/Remove_SecurityComp.reg 负责安全中心 UI 层清理。逐份解读如下。
服务与驱动删除:RemoveServices.reg
该文件通过删除 HKLM\SYSTEM\CurrentControlSet\Services 下的服务键来"物理移除"服务注册,覆盖:
| 服务名 | 作用(由服务名推断) |
|---|---|
WinDefend |
Windows Defender 防病毒主服务 |
WdBoot |
Defender 早期启动(ELAM)驱动 |
WdFilter |
Defender 文件系统过滤驱动 |
WdNisDrv / WdNisSvc |
网络检查系统(NIS)驱动与服务 |
MsSecCore / MsSecFlt / MsSecWfp |
Microsoft Security 核心/过滤驱动 |
wscsvc |
安全中心服务 |
SgrmAgent / SgrmBroker |
安全监管代理/守护(Security Health 运行依赖) |
whesvc |
Windows 硬件错误服务(该文件将其一并移除) |
webthreatdefsvc / webthreatdefusersvc |
Windows Web 威胁防御服务(并删除 Svchost\WebThreatDefense 分组注册) |
PlutonHsp2 / PlutonHeci / Hsp |
Pluton 安全处理器相关服务 |
同时它会在 SOFTWARE\Policies\Microsoft\Windows Defender Security Center\App and Browser protection 下写入 DisallowExploitProtectionOverride=1,禁止覆盖 exploit 保护设置。
杀毒 CLSID 与日志器移除:RemovalofWindowsDefenderAntivirus.reg
该文件在 HKLM\Software\Classes、HKLM\Software\Classes\WOW6432Node、HKEY_CLASSES_ROOT(含 32 位节点)三处,删除 13 个与 Defender 关联的 CLSID 键(如 {2781761E-28E0-4109-99FE-B9D127C57AFE}、{195B4D07-3DE2-4744-BBF2-D90121AE785B} 等,对应 Defender 的 COM 组件注册),并在文件末尾删除两个 WMI 自动日志器:
; Defender Loggers
[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger]
[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DefenderApiLogger]
强制禁用策略:DisableDefenderPolicies.reg 与 DisableAntivirusProtection.reg
DisableDefenderPolicies.reg 是目前仓库中最庞大的策略文件,把 Defender 各功能在 MDM 策略通道 HKLM\SOFTWARE\Microsoft\PolicyManager\default\Defender 下全部置 0(禁用),包括:
AllowIOAVProtection、AllowRealtimeMonitoring、AllowBehaviorMonitoring、AllowOnAccessProtection(实时/行为/按访问监控);AllowCloudProtection、AllowEmailScanning、AllowScriptScanning、AllowScanningNetworkFiles、AllowFullScanRemovableDriveScanning、AllowFullScanOnMappedNetworkDrives、AllowArchiveScanning、AllowIntrusionPreventionSystem;DisableCatchupFullScan/DisableCatchupQuickScan= 1(关闭追赶扫描);EnableControlledFolderAccess= 0(受控文件夹访问)、EnableNetworkProtection= 0(网络保护);- 计划扫描参数:
ScheduleScanDay/ScheduleScanTime/ScanParameter= 2(快速扫描)/AvgCPULoadFactor= 0x32(50%)等。
在组策略通道 HKLM\SOFTWARE\Policies\Microsoft\Windows Defender 下,它设置 DisableAntiSpyware=1、DisableRoutinelyTakingAction=1、ServiceKeepAlive=0、AllowFastServiceStartup=0、DisableLocalAdminMerge=1,并分别覆盖 Real-Time Protection、Scan、Signature Updates、Spynet、UX Configuration、Exploit Guard(Controlled Folder Access / Network Protection)各子节;此外还在 SOFTWARE\Policies\Microsoft\Microsoft Antimalware 下写入 DisableAntiVirus=1,并从 CI(代码完整性)策略中关闭 VerifiedAndReputablePolicyState。
DisableAntivirusProtection.reg 则是上述内容的精简版,重点在于禁用实时保护且禁止本地覆盖(LocalSettingOverride* 全部置 0),并附带 RemovalTools\MpGears 下的 HeartbeatTrackingIndex=0、SpyNetReportingLocation="0",用于切断 MpGears 遥测通道。
系统缓解与 Tamper Protection:Disable Mitigation.reg
该文件处理 README 中提到的"System Mitigations"与 Tamper Protection:
HKLM\SOFTWARE\Microsoft\WindowsMitigation的UserPreference=2;- 内核缓解:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel下的MitigationOptions/MitigationAuditOptions(十六进制位掩码)以及KernelSEHOPEnabled=0; - 服务缓解:
Control\SCMConfig的EnableSvchostMitigationPolicy置 0; - Tamper Protection:
SOFTWARE\Microsoft\Windows Defender\Features下将TamperProtection、TamperProtectionSource、MpPlatformKillbitsFromEngine、MpCapability全部置 0,同时关闭RunAsPPL(保护进程轻量级)与LsaConfigFlags、RunAsPPLBoot; - 驱动黑名单:
Control\CI\Config的VulnerableDriverBlocklistEnable=0,对应 README 中移除的 Microsoft Driver Block List。
SmartScreen 全面禁用:Disable SmartScreen.reg
覆盖三个层面的 SmartScreen:
- Microsoft Edge(旧版与新版):
AppContainer\...\MicrosoftEdge\PhishingFilter的EnabledV9=0、PreventOverride=0;Software\Microsoft\Edge的SmartScreenEnabled=0; - 文件资源管理器 / Windows Shell:
Explorer的SmartScreenEnabled="off"、Policies\Microsoft\Windows\System的EnableSmartScreen=0,并删除ShellSmartScreenLevel; - Microsoft Store 应用:
AppHost的EnableWebContentEvaluation=0、PreventOverride=0;同时在 MDM 通道PolicyManager\default\Browser\AllowSmartScreen、SmartScreen\EnableSmartScreenInShell、SmartScreen\EnableAppInstallControl、SmartScreen\PreventOverrideForFilesInShell全部置 0。
通知与安全中心静默:DisableDefenderandSecurityCenterNotifications.reg
- MDM 通道
WindowsDefenderSecurityCenter\DisableEnhancedNotifications、DisableNotifications、HideWindowsSecurityNotificationAreaControl置 1; - 重建
HKLM\SOFTWARE\Microsoft\Security Center为FirstRunDisabled=1、AntiVirusOverride=1、FirewallOverride=1; - 组策略
Policies\...\Notifications的DisableNotifications=1、DisableEnhancedNotifications=1; - 用户级禁用
Windows.SystemToast.SecurityAndMaintenance通知的Enabled=0。
计划任务、启动项与签名更新
- RemoveDefenderTasks.reg:删除
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks下 4 个 GUID 任务(对应 Defender 扫描/维护计划任务缓存); - RemoveStartupEntries.reg:删除 HKCU/HKLM
Run与StartupApproved\Run下的Windows Defender、SecurityHealth、WindowsDefender启动项; - RemoveSignatureUpdates.reg:将
Policies\Microsoft\Windows Defender\Signature Updates下SignatureDisableNotification=1、RealtimeSignatureDelivery=0、ForceUpdateFromMU=0、UpdateOnStartUp=0、DisableScanOnUpdate=1等,使签名(病毒库)更新通道失效。
Shell 关联、右键菜单与设置页
- RemoveShellAssociation.reg:删除
windowsdefenderURL 关联、AppUserModelId\Windows.Defender与Microsoft.Windows.Defender、防火墙 RestrictServices 下的WindowsDefender-1/2/3规则,以及Control\Ubpm下的CriticalMaintenance_DefenderCleanup/CriticalMaintenance_DefenderVerification维护项; - RemoverofDefenderContextMenu.reg:删除
Explorer\ShellServiceObjects\{900c0763-...}、Folder\shell\WindowsDefender、DesktopBackground\Shell\WindowsSecurity等右键菜单注册; - WindowsSettingsPageVisibility.reg:写入
Explorer的SettingsPageVisibility="hide:windowsdefender;",从设置应用中隐藏 Windows 安全页面; - RemoveWindowsWebThreat.reg:删除 Web 威胁防御的 CLSID 与
ActivatableClassId注册(Microsoft.OneCore.WebThreatDefense.*)、webthreatdefsvc/webthreatdefusersvc服务、防火墙出入站规则,并将PolicyManager\default\WebThreatDefense的ServiceEnabled、AuditMode、NotifyUnsafeOrReusedPassword全部置 0。
安全中心 UI 层:Remove_SecurityComp/Remove_SecurityComp.reg
该文件在 HKLM / HKCU 下删除 "Windows Security Health" 相关数据,写入 State\Disabled=1、Platform\Registered=0;删除安全中心在控制面板的 CLSID 命名空间 {BB64F8A7-BEE7-4E1A-AB8D-7D8273F7FDB6}(对应"安全和维护"入口),并删除 SecurityHealthService 服务键。这与模块 Remove_SecurityComp/README.md 的描述一致:移除 Windows 安全 UWP 应用(SecHealthUI)、wscsvc 安全中心服务、设置应用中的安全分区和任务栏盾牌图标。
高级:移除 Windows Defender Application Guard 策略文件
README 的 "Disable or Remove Windows Defender Application Guard Policies (advanced)" 一节给出了一个罕见但典型的排障场景:打开应用时报 "The app can not run because Device Guard" 或 "Windows Defender Application Guard Blocked this app"。此时需要删除 4 个同名文件(WiSiPolicy.p7b,位置不同):
- EFI 分区:
Remove-Item -LiteralPath "$((Get-Partition | ? IsSystem).AccessPaths[0])Microsoft\Boot\WiSiPolicy.p7b"
- 代码完整性目录:
Remove-Item -LiteralPath "$env:windir\System32\CodeIntegrity\WiSiPolicy.p7b"
- Windows 目录:
Remove-Item -LiteralPath "$env:windir\Boot\EFI\wisipolicy.p7b"
- WinSxS 组件存储:
Remove-Item -Path "$env:windir\WinSxS" -Include *winsipolicy.p7b* -Recurse
制作"开箱免 Defender"的定制 Windows ISO
根目录 README 与 ISO Maker/README.md 共同描述了 ISO Maker 模块的用法。其核心收益是:Defender 在首次启动(OOBE)前就不会运行,且能阻止 Windows Update 在安装过程中重新拉回相关组件。
目录结构与两种介质
需要手工在 ISO 内创建三层嵌套目录(必须在 sources 文件夹内,这是 Windows 安装程序扫描 $OEM$ 的约定位置):
sources
└── $OEM$
└── $$
└── Panther
完整路径示例:C:\ISOFolder\sources\$OEM$\$$\Panther\
- DVD 介质流程:挂载 ISO → 解压到目录 → 按上述结构建目录 → 将 autounattend.xml(或 unattend.xml)放入
Panther文件夹 → 用 AnyBurn / ImgBurn 之类工具把整个目录重新打包为可引导 ISO。 - U 盘介质流程:先用 Rufus 制作可引导 U 盘 → 同样在
sources下建$OEM$\$$\Panther→ 将 unattend 文件放入Panther→ 另将 autounattend.xml 复制一份到 U 盘根目录(官方注明:这用于阻止进行"就地升级"in-place upgrades)。
注意:该方法利用的是 Windows 安装程序的
unattend.xml机制,如果你还使用了其他定制工具,需确保不存在互相冲突的无应答文件。
autounattend.xml 的免 Defender 原理
仓库提供了两份结构相同的应答文件:ISO_Maker/autounattend.xml 与 ISO_Maker/sources//$$/Panther/autounattend.xml(后者是安装时真正被消费的副本)。从文件内容看,其"免 Defender"能力由三个阶段配合完成:
1. windowsPE 阶段(安装程序早期):先写入 HKLM\SYSTEM\Setup\LabConfig 下的 BypassTPMCheck、BypassSecureBootCheck、BypassRAMCheck 三项(跳过 TPM/安全启动/内存硬件检查);随后通过 15 条 RunSynchronousCommand 逐行拼接生成 X:\defender.vbs 脚本并后台启动(cscript.exe //E:vbscript X:\defender.vbs)。该 VBS 的逻辑是:扫描所有磁盘上新生成的 System32\config\SYSTEM 注册表 hive(区分 $Windows.~BT\NewOS\Windows 与正常 Windows 路径,并跳过安装程序启动前就已存在的文件),用 reg.exe LOAD HKLM\mount 挂载后,将 6 个服务(Sense、WdBoot、WdFilter、WdNisDrv、WdNisSvc、WinDefend)的 Start 值写为 4(禁用),最后 reg.exe UNLOAD 卸载。这正是"首次启动前 Defender 服务即被禁用"的实现。
2. specialize 阶段(系统定制):由 Microsoft-Windows-Deployment 的同步命令依次执行:用内嵌 ExtractScript 从 <Extensions><File> 节点解压出 Specialize.ps1、DefaultUser.ps1、FirstLogon.ps1 与暂停更新计划任务到 C:\Windows\Setup\Scripts\;然后执行 Specialize.ps1 中的脚本序列,包括:允许不支持的 TPM/CPU 升级、BypassNRO=1、net accounts /maxpwage:UNLIMITED、注册 7 天暂停 Windows Update 的 PauseWindowsUpdate 计划任务、关闭安全中心通知、关闭 VerifiedAndReputablePolicyState、SmartScreenEnabled="Off"、关闭 WTDS 组件(ServiceEnabled/NotifyMalicious/NotifyPasswordReuse/NotifyUnsafeApp)、HideSystray=1、PreventDeviceEncryption=1(BitLocker 设备加密)、以及将 DeviceGuard 的 EnableVirtualizationBasedSecurity 与 HypervisorEnforcedCodeIntegrity 的 Enabled/EnabledBootId/WasEnabledBy 全部置 0(禁用 VBS/HVCI)。
3. oobeSystem / FirstLogon 阶段:oobeSystem 创建 Admin(管理员组)与 User(普通用户组)两个本地账户,配置 Admin 自动登录 1 次,ProtectYourPC=3;首次登录时 FirstLogon.ps1 把 AutoLogonCount 复位为 0,并清理 C:\Windows\Panther\unattend.xml、unattend-original.xml、Wifi.xml 等临时文件。
其中 PauseWindowsUpdate 计划任务由 PauseWindowsUpdate.ps1 实现:将 HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings 下的 PauseFeatureUpdatesStartTime/EndTime、PauseQualityUpdatesStartTime/EndTime、PauseUpdatesStartTime/PauseUpdatesExpiryTime 设置为当前时间起 7 天,任务触发方式为每次开机(BootTrigger,Interval P1D)由 S-1-5-19(本地服务)以最低权限执行。
手动移除 Windows 安全应用(不下载脚本的方式)
README 的 FAQ 给出了"不下载脚本、手动移除 Windows 安全中心/安全应用"的完整 PowerShell 代码,RemoveSecHealthApp.ps1 即是该代码的仓库内实现。将代码保存为 .ps1 后以管理员身份运行即可:
$remove_appx = @("SecHealthUI"); $provisioned = get-appxprovisionedpackage -online; $appxpackage = get-appxpackage -allusers; $eol = @()
$store = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore'
$users = @('S-1-5-18'); if (test-path $store) {$users += $((dir $store -ea 0 |where {$_ -like '*S-1-5-21*'}).PSChildName)}
foreach ($choice in $remove_appx) { if ('' -eq $choice.Trim()) {continue}
foreach ($appx in $($provisioned |where {$_.PackageName -like "*$choice*"})) {
$next = !1; foreach ($no in $skip) {if ($appx.PackageName -like "*$no*") {$next = !0}} ; if ($next) {continue}
$PackageName = $appx.PackageName; $PackageFamilyName = ($appxpackage |where {$_.Name -eq $appx.DisplayName}).PackageFamilyName
ni "$store\Deprovisioned\$PackageFamilyName" -force >''; $PackageFamilyName
foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageName" -force >''} ; $eol += $PackageName
dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''
remove-appxprovisionedpackage -packagename $PackageName -online -allusers >''
}
foreach ($appx in $($appxpackage |where {$_.PackageFullName -like "*$choice*"})) {
$next = !1; foreach ($no in $skip) {if ($appx.PackageFullName -like "*$no*") {$next = !0}} ; if ($next) {continue}
$PackageFullName = $appx.PackageFullName;
ni "$store\Deprovisioned\$appx.PackageFamilyName" -force >''; $PackageFullName
foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageFullName" -force >''} ; $eol += $PackageFullName
dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''
remove-appxpackage -package $PackageFullName -allusers >''
}
}
这段脚本的原理是:先取 SecHealthUI 的预置(provisioned)包与已安装包,在 AppxAllUserStore 下写入 Deprovisioned 与各用户 SID 下的 EndOfLife 标记(阻止应用商店/更新重新部署),再用 dism /online /set-nonremovableapppolicy ... /nonremovable:0 把该包标记为"可移除",最后分别调用 remove-appxprovisionedpackage(预置包)与 remove-appxpackage(已安装包)完成卸载。
若要以最高权限执行该脚本,可使用仓库根目录提供的 PowerRun.exe,命令格式(见 Remove_SecurityComp/README.md):
Powerrun powershell.exe -noprofile -executionpolicy bypass -file "RemoveSecHealthApp.ps1"
提示:使用 package remover(各
.bat)而不下载 Release 可执行文件时,README 建议把目标.bat拖到 PowerRun.exe 上运行;更改必须重启后才会生效。
常见问题(FAQ)要点
根目录 README 收录了几类高频问题,此处按原文档逐条整理:
- 下载的 .exe 被杀毒软件报毒? 项目官方说明这是误报:由于
.exe的打包方式,部分安全软件会将其标记为病毒;改用 git 或源码 .zip 方式获取则不会报毒。同时官方自述:自 Defender 12.6.x 起,某些版本被判定为病毒、某些不会(官方称之为自身缺陷,不建议因此提交 issue)。 - Windows 更新后补丁失效? Windows Update 会携带 Intelligence Update,它会阻止某些操作并修改 Defender/安全策略。若脚本失效,请检查是否安装了 Windows 安全智能更新;如已安装,先禁用 Tamper Protection(篡改防护)再重新运行脚本。
- 如何不下载 Release 可执行文件使用包移除器? 将目标
.bat从 cmd 拖到 PowerRun.exe 上运行,重启后生效。 - 移除脚本失效时如何手动禁用 VBS? 执行
bcdedit /set hypervisorlaunchtype off并重启;注意此后将无法使用虚拟机。 - 为什么 Windows 11 上 VBS 会被反复重新启用? 官方解释:脚本默认禁用 VBS 以换取性能,但 Windows Virtualization 会把它拉回启用状态,触发场景包括:Windows Subsystem for Android / Linux(Hyper-V 虚拟机)、Microsoft Emulator(Microsoft Store 中的 Windows 10X 模拟器)、以及 Visual Studio 中集成 Android Studio 或其他模拟器(适用于 2025 年 3 月更新或更新版本的 Windows 10 22H2)。只要打开上述任一应用,VBS 就会在用户无感知的情况下重新启用——因为它要为虚拟机引擎提供支撑。若你从不使用虚拟机,可按官方指引提交 issue。
风险提示与使用边界
最后需要重申 README 开头与 FAQ 中反复强调的几点,作为使用前提:
- 务必先创建系统还原点,脚本执行后会自动
shutdown /r /f /t 10强制重启; - 工具移除的是 Windows 自带安全组件,会显著改变系统安全姿态,禁用 UAC(LUA)后所有应用将以管理员权限运行,请确认理解该后果;
- 禁用 VBS 会影响依赖 Hyper-V 的虚拟化功能(WSL/WSA/模拟器);
- 仓库是只读资料源,本文仅介绍查看、运行与配置方式;动手前请核对当前仓库中 Script_Run.bat、Remove_Defender 与 ISO_Maker 各文件的实际内容与版本(当前
Script_Run.bat声明版本为 13.0)。