Windows ファイル ディフェンダーに除外を追加するスクリプトが必要な場合は、次のテキストを .bat ファイルとして保存して実行することで、次のような操作を実行できます。
powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath "mypath"
しかし、同様の方法で Windows Defender にレジストリ エントリの例外を追加したい場合はどうすればよいでしょうか? Windows Defender にレジストリ エントリを例外として追加することは可能ですか?
答え1
本当の答えではありませんが、レジストリを通じて実行します。ここに情報があります:
ファイルとフォルダーの除外は、以下のレジストリ キーに保存されます。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths
ファイル タイプの除外は、以下のレジストリ キーに保存されます。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exclusions\Extensions
プロセスの除外は以下のレジストリ キーに保存されます。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exclusions\Processes
心から、
アルバロ・ラマドリッド
答え2
ご覧のとおり、次のコードを使用して Powershell で例外を作成できます。
Add-MpPreference -ExclusionPath %NameOfThePathOrFile% -Force
-Force コマンドは、ユーザー確認をバイパスするためのものです。
仕事に必要なその他の機能は、PowerShell を (少なくとも) 管理者として実行することです。次の方法で実行できます。
reg query "HKU\S-1-5-19\Environment" >nul 2>&1
if not %errorlevel% EQU 0 (
cls
powershell.exe -windowstyle hidden -noprofile "Start-Process '%~dpnx0' -Verb RunAs"
exit
)
まず、次のように goto を作成できます。
goto Admin
START Powershell -nologo -noninteractive -windowStyle hidden -noprofile -command ^
Add-MpPreference -ExclusionPath %NameOfThePath% -Force;
:Admin
reg query "HKU\S-1-5-19\Environment" >nul 2>&1
if not %errorlevel% EQU 0 (
cls
powershell.exe -windowstyle hidden -noprofile "Start-Process '%~dpnx0' -Verb RunAs"
exit
)
お役に立てれば幸いです。