Document toolboxDocument toolbox

Configuring virus scanner full path with additional options

Introduction


You need to write a custom script to append additional options (e.g. -Scan) to the virus scanner full path

Finding shortened path for a directory

For Windows environment, if your file path contains spaces (e.g. C:\Program Files), you need to use cmd to find the shortened path for the directory (e.g. c:\progra~1) to remove the spaces.

  1. Open cmd
  2. Navigate to desired directory
  3. Execute the following command

    dir /x
  4. The shorthand for the directory would be displayed  

Script Template

For Windows Defender, the command line scanner requires additional options to perform an on-demand scan for a specific file.

  1. Create a batch file script (e.g. c:\atlassian\atlassian-jira-software-7.8.1-standalone\bin\scanner.cmd) using the following template

    Replace "c:\progra~1\window~1\MpCmdRun.exe -Scan -ScanType -File" accordingly

    scanner.cmd
    @echo off
    REM echo executing scan for file %1
    c:\progra~1\window~1\MpCmdRun.exe -Scan -ScanType 3 -File "%1"
    
    REM exit the script by the exit code from MpCmdRun.exe but do not exit the cmd.exe
    EXIT /B %ERRORLEVEL%
  2. Append the path of the script to the Attachment Checker Virus Scanning configurations in the Full Path for Scanner field

Notes

CommandParameterDescriptionReferences
MpCmdRun.exe-Scan -ScanType 3

Define the type of scan to be executed

0 - Default, according to the configuration

1 - Quick scan

2 - Full System Scan

3 - File and directory custom scan

https://superuser.com/questions/481862/how-can-you-scan-from-the-command-line-with-windows-defender
-File "%1"Indicates the file or directory to be scanned. Only valid for custom scans.
Exit/BOnly exit the script. Do not exit the cmd.exe
https://ss64.com/nt/exit.html
%ERRORLEVEL%Exit with the status code given by the previous executed command