您现在的位置是:首页 >技术教程 >永久禁用Windows Defender代码方案(可恢复)【支持Windows10、Windows11】网站首页技术教程

永久禁用Windows Defender代码方案(可恢复)【支持Windows10、Windows11】

夜栩 2024-10-11 00:01:03
简介永久禁用Windows Defender代码方案(可恢复)【支持Windows10、Windows11】

永久禁用Windows Defender代码方案(可恢复)【支持Windows10、Windows11】

代码文件下载地址:
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+="Windowssystem32SgrmBroker.exe"
$array+="Windowssystem32SgrmSgrmBroker.exe"
#SecurityHealthService:Windows 安全中心服务
$array+="Windowssystem32SecurityHealthService.exe"
 
#Sense:Windows Defender Advanced Threat Protection Service
$array+="Program FilesWindows Defender Advanced Threat ProtectionMsSense.exe"
 
#WdNisDrv:Microsoft Defender Antivirus Network Inspection System Driver
$array+="WindowsSystem32driversWdNisDrv.sys"
$array+="WindowsSystem32driverswdWdNisDrv.sys"
#WdBoot:Microsoft Defender Antivirus Boot Driver
$array+="WindowsSystem32driversWdBoot.sys"
$array+="WindowsSystem32driverswdWdBoot.sys"
#WdFilter:Microsoft Defender Antivirus Mini-Filter Driver
$array+="WindowsSystem32driversWdFilter.sys"
$array+="WindowsSystem32driverswdWdFilter.sys"
#
$array+="WindowsSystem32driversWdDevFlt.sys"
$array+="WindowsSystem32driverswdWdDevFlt.sys"
 
#
$array+="WindowsSystem32smartscreen.exe"
 
#
#WinDefend:Windows Defender Service/Microsoft Defender Antivirus Service
$array+="Program FilesWindows DefenderMsMpEng.exe"
#WdNisSvc:Windows Defender Network Inspection Service/Microsoft Defender Antivirus Network Inspection Service
$array+="Program FilesWindows DefenderNisSrv.exe"
#
$array+="Program FilesWindows DefenderMpCmdRun.exe"
#
$array+="Program FilesWindows DefenderMpUXSrv.exe"
#
$array+="Program FilesWindows DefenderConfigSecurityPolicy.exe"
#
$array+="Program FilesWindows DefenderMpCopyAccelerator.exe"
#
$array+="Program FilesWindows DefenderMpDlpCmd.exe"
#
$array+="Program FilesWindows Defendermpextms.exe"
#
$array+="Program FilesWindows DefenderNisSrv.exe"
#
$array+="Program FilesWindows DefenderMpSvc.dll"
#
$array+="Program FilesWindows DefenderOfflineOfflineScannerShell.exe"
#
$array+="Program FilesWindows DefenderX86MpCmdRun.exe"
#
$DenyAcl_Files_Array=Get-ChildItem "C:ProgramDataMicrosoftWindows DefenderPlatform*" -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)}}

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。