永久禁用Windows Defender代码方案(可恢复)【支持Windows10、Windows11】
永久禁用Windows Defender代码方案(可恢复)【支持Windows10、Windows11】
https://blog.csdn.net/m0_60961651/article/details/131090391
代码文件下载地址:
https://cloud.189.cn/t/jaieM3raeYjy
视频演示文件下载地址:
禁用操作(PowerShell要以管理员身份运行,视频演示不规范):
https://cloud.189.cn/t/fUV773r22Mnq
恢复操作(PowerShell要以管理员身份运行,视频演示不规范):
https://cloud.189.cn/t/VnY3uyqIRn2u
非电信手机号码,直接验证码登陆即可注册天翼云盘
禁用操作:
cmd运行命令:shutdown -f -r -o -t 0
选择【疑难解答】-【高级选项】-【启动设置】-【重启】,然后按4键进入安全模式
以管理员身份打开PowerShell,复制代码回车后,输入YES回车。
即可禁用Windows Defender。
(输入非YES的其它任意字符回车是恢复Windows Defender)
恢复操作:
cmd运行命令:shutdown -f -r -o -t 0
选择【疑难解答】-【高级选项】-【启动设置】-【重启】,然后按4键进入安全模式
以管理员身份打开PowerShell,复制代码回车后,输入NO回车。
即可恢复Windows Defender。
(输入非YES的其它任意字符回车是恢复Windows Defender)
代码例程:
#使用说明:cmd运行命令:【shutdown -f -r -o -t 0】进入安全模式后,按一下Windows键,输入ISE来搜索【Windows PowerShell ISE】,右击,以管理员身份运行。
#复制所有内容到【Windows PowerShell ISE】下面的紫色输入框,回车后即可操作。
#输入YES回车后禁用Windows Defender,输入其它内容回车后恢复Windows Defender
#运行完后重启电脑。
Function AddDenyAcl($temp)
{$User_or_Group_NAME=$temp[0]
$Acl_Object=$temp[1]
if(Test-Path $Acl_Object)
{echo $Acl_Object":存在"
$acl=Get-Acl $Acl_Object
$acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(([System.Security.Principal.NTAccount]$User_or_Group_NAME),([System.Security.AccessControl.FileSystemRights]"FullControl"),([System.Security.AccessControl.InheritanceFlags]"None"),([System.Security.AccessControl.PropagationFlags]"None"),([System.Security.AccessControl.AccessControlType]"Deny"))))
Set-Acl $Acl_Object $acl}
else{echo $Acl_Object":不存在"}}
Function RemoveDenyAcl($temp)
{$User_or_Group_NAME=$temp[0]
$Acl_Object=$temp[1]
if(Test-Path $Acl_Object)
{echo $Acl_Object":存在"
$acl=Get-Acl $Acl_Object
$acl.RemoveAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(([System.Security.Principal.NTAccount]$User_or_Group_NAME),([System.Security.AccessControl.FileSystemRights]"FullControl"),([System.Security.AccessControl.InheritanceFlags]"None"),([System.Security.AccessControl.PropagationFlags]"None"),([System.Security.AccessControl.AccessControlType]"Deny"))))
Set-Acl $Acl_Object $acl}
else{echo $Acl_Object":不存在"}}
Set-Location C:
$array=@()
#SgrmBroker:System Guard 运行时监视代{过}{滤}理
$array+="\Windows\system32\SgrmBroker.exe"
$array+="\Windows\system32\Sgrm\SgrmBroker.exe"
#SecurityHealthService:Windows 安全中心服务
$array+="\Windows\system32\SecurityHealthService.exe"
#Sense:Windows Defender Advanced Threat Protection Service
$array+="\Program Files\Windows Defender Advanced Threat Protection\MsSense.exe"
#WdNisDrv:Microsoft Defender Antivirus Network Inspection System Driver
$array+="\Windows\System32\drivers\WdNisDrv.sys"
$array+="\Windows\System32\drivers\wd\WdNisDrv.sys"
#WdBoot:Microsoft Defender Antivirus Boot Driver
$array+="\Windows\System32\drivers\WdBoot.sys"
$array+="\Windows\System32\drivers\wd\WdBoot.sys"
#WdFilter:Microsoft Defender Antivirus Mini-Filter Driver
$array+="\Windows\System32\drivers\WdFilter.sys"
$array+="\Windows\System32\drivers\wd\WdFilter.sys"
#
$array+="\Windows\System32\drivers\WdDevFlt.sys"
$array+="\Windows\System32\drivers\wd\WdDevFlt.sys"
#
$array+="\Windows\System32\smartscreen.exe"
#
#WinDefend:Windows Defender Service/Microsoft Defender Antivirus Service
$array+="\Program Files\Windows Defender\MsMpEng.exe"
#WdNisSvc:Windows Defender Network Inspection Service/Microsoft Defender Antivirus Network Inspection Service
$array+="\Program Files\Windows Defender\NisSrv.exe"
#
$array+="\Program Files\Windows Defender\MpCmdRun.exe"
#
$array+="\Program Files\Windows Defender\MpUXSrv.exe"
#
$array+="\Program Files\Windows Defender\ConfigSecurityPolicy.exe"
#
$array+="\Program Files\Windows Defender\MpCopyAccelerator.exe"
#
$array+="\Program Files\Windows Defender\MpDlpCmd.exe"
#
$array+="\Program Files\Windows Defender\mpextms.exe"
#
$array+="\Program Files\Windows Defender\NisSrv.exe"
#
$array+="\Program Files\Windows Defender\MpSvc.dll"
#
$array+="\Program Files\Windows Defender\Offline\OfflineScannerShell.exe"
#
$array+="\Program Files\Windows Defender\X86\MpCmdRun.exe"
#
$DenyAcl_Files_Array=Get-ChildItem "C:\ProgramData\Microsoft\Windows Defender\Platform\*\" -include MsMpEng.exe,NisSrv.exe,MpCmdRun.exe,MpUXSrv.exe,ConfigSecurityPolicy.exe,MpCopyAccelerator.exe,MpDlpCmd.exe,mpextms.exe,NisSrv.exe,MpSvc.dll,OfflineScannerShell.exe -recurse
$DenyAcl_Files_items=$DenyAcl_Files_Array.FullName
$array+=$DenyAcl_Files_items
$Everyone_User_NAME="Everyone"
$Is_Recovery_Item=Read-Host '是否需要禁止“Windows Defender”?【YES=“禁止”,其它字符回车=“还原”】 '
if($Is_Recovery_Item -eq "YES")
{echo "Yes,接下来禁止"“Windows Defender"”"
for($i=0;$i -lt $array.length;$i++)
{$String=$array[$i]
AddDenyAcl($Everyone_User_NAME, $String)}}
else
{echo "No,接下来还原"“Windows Defender"”"
for($i=0;$i -lt $array.length;$i++)
{$String=$array[$i]
RemoveDenyAcl($Everyone_User_NAME, $String)}}
————————————————
版权声明:本文为CSDN博主「夜栩」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_60961651/article/details/131090391