Open bagarwa opened 1 month ago
I have disabled the anti-virus software,but you can try
I have disabled the anti-virus software,but you can try https://learn.microsoft.com/en-us/defender-endpoint/command-line-arguments-microsoft-defender-antivirus
That's just a command-line util though. It runs the command in the terminal itself and not in Defender GUI. For example -
C:\Users\Test>"C:\program files\windows defender\mpcmdrun.exe" -scan -scantype 3 -File "test.zip"
Scan starting...
Scan finished.
Scanning test.zip found no threats.
Moreover, when I add that command as a context menu option in the CCM app, save, right click any file and click this option, the terminal window opens and closes within fraction of seconds. I'm guessing the scan runs, finishes, and closes; as mpcmdrun itself isn't a terminal window but terminal util.
Anyway, I am looking for a way to trigger the Defender GUI. i.e. replicate the exact behavior of the "Scan with Microsoft Defender" option, but in the modern context menu, instead of classic context menu.
Configure ContextMenuForWindows11 as follows to prevent the window from closing automatically:
Option | Value |
---|---|
Exe | cmd.exe |
Param | /k MpCmdRun.exe -Scan -ScanType 3 -File "{path}" -DisableRemediation |
[!NOTE]
Set the-DisableRemediation
option to ignore file and directory exclusions, also actions are not applied after detection.
Note that MpCmdRun.exe
must be in the PATH
environment variable:
powershell
, and press Enter.PATH
env var:$DIR = "%ProgramFiles%\Windows Defender"
$PATH = [Environment]::GetEnvironmentVariable("PATH", "User")
[System.Environment]::SetEnvironmentVariable("PATH", "$PATH;$DIR", "User")
You can invoke the Scan with Microsoft Defender
item from the context menu to open the GUI.
shellext.ahk
and paste the following code:shellext.ahk
, show more options, click Compile script
.shellext.exe
in a static directory (e.g. C:
) and configure ContextMenuForWindows11 as follows:Config | Value |
---|---|
Exe | C:\shellext.exe |
Param | "{path}" |
[!NOTE]
- I barely tested the use of the context menu, you should probably stick with the CLI.
- I have used AutoHotkey because it is pretty easy to use for this kind of thing.
That worked great. Thanks for the detailed write-up. Really appreciate it.
Issue
In Windows 11, if I want to scan any file / folder for security issue, I have to right click it to bring modern context menu, then click "Show More options" to bring classic context menu and then click "Scan with Microsoft Defender".
I want to bring this to the modern context menu itself.
Tried
I figured if I can add the Defender's exe to CCM setting, I can probably get it working. But I couldn't find proper exe location -
C:\Program Files\Windows Defender\
has 3 exe, none of which seem to be correct one.`C:\Program Files\Windows Defender Advanced Threat Protection\' too has bunch of exe but I'm not sure which one is correct.
Question
Is this even doable? If yes, can someone please help me with it?