none
How to run a windows defender scan and display scan results returned in command prompt in new window with the scan results as the title? RRS feed

  • General discussion

  • Hi guys, 

    I am trying to run a windows defender scan and display the scan results returned in command prompt in  new window with the scan results as the title? I intend to do this using a .bat script. This is my code when i test in cmd prompt directly, but there is an error  returned: "["delims="] was unexpected at this time.". Can anyone help? thank you. 

    Code:

    FOR /F ["delims="] %I IN ("%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File D:\) DO (start %I)

    • Changed type Bill_Stewart Friday, January 26, 2018 3:20 PM
    • Moved by Bill_Stewart Friday, January 26, 2018 3:20 PM Unanswerable/abandoned
    Wednesday, December 6, 2017 6:26 AM

All replies

  • This is not a Windows Defender forum.  You cannot use a batch file in this way.  It won't work. 

    Forum for defender issues.

    https://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserversecurity


    \_(ツ)_/

    Wednesday, December 6, 2017 8:25 AM
  • The main issue is how to launch and display a cmd prompt output in a new window. Can you elaborate on cannot use a batch file this way? 
    Wednesday, December 6, 2017 9:53 AM
  • This is not a forum for teaching how to use batch files.  You batch command is pointless as it is not a legitimate command.

    To open a new command window you would use "start"

    start /?

    TO understand what "FOR" is used for see:

    FOR /?

    Follow the instructions.


    \_(ツ)_/

    Wednesday, December 6, 2017 10:11 AM
  • not very helpful advice and I don't think you understand the question. Looking at your other replies on other threads, i guess this seems to be you, so not going to response to any further replies from you.

    ___

    Any other kind souls which can provide useful advice to the question? thanks in advance! 

     
    Wednesday, December 6, 2017 10:19 AM
  • Type the following:

    start "My new window" cmd /k

    Now copy and paste this into test.bat:

    "c:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File D:\

    Now copy and paste this at a CMD prompt:

    start "My new window" test.bat

    That is how to create a new window with a custom title.


    \_(ツ)_/

    Wednesday, December 6, 2017 11:15 AM
  • FOR /F ["delims="] %I IN ("%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File D:\) DO (start %I)

    1. The delims= syntax you are using is not valid. In syntax descriptions, code in between [ ] characters means "this is optional." You don't actually literally enter the [ ] characters.

    2. In a batch file script, the syntax %I is not valid. You must double the % characters.

    3. PowerShell is to be preferred over batch.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, December 6, 2017 3:51 PM
  • Thanks Bill for guiding this beginner here.  

    I have tried to remove the [] and added the %. But CMD returns the following error message: 

    "The system cannot find the file C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File D:\."

    Do you know what is the issue? 

    Thanks again.

    Thursday, December 7, 2017 2:55 AM
  • The question still is --- Why are you using "FOR"?  It serves no purpose here.  It cannot be used as you are trying to use it.  Remove the FRO and just run the program as I showed you above.


    \_(ツ)_/

    Thursday, December 7, 2017 3:00 AM
  • what you have shared cannot work.
    Thursday, December 7, 2017 3:10 AM
  • and it is not what I am looking for
    Thursday, December 7, 2017 3:10 AM
  • I want the new window' title to display the scan results return, not a dummy "my new window"

    Thursday, December 7, 2017 3:11 AM
  • I want the new window' title to display the scan results return, not a dummy "my new window"

    The new window displays the scan results.  Apparently you didn't even try it.

    To make the display persist just add "pause" tot eh end of the batch file.

    If you would actually take the time to read the help and test the examples to learn how things work you would find less things to complain about.

    The broad assumption in technical forums is that you are a technician.  Apparently you are not so this is all very difficult and contentious.

    Stop being so indignant about not getting instant gratification and turn you brain on.  You can figure this out if you are willing to put in some effort.


    \_(ツ)_/

    Thursday, December 7, 2017 3:16 AM
  • have tried and it is not working. as I have said, your advice isnt useful at all. would appreciate if you can leave this thread alone and let others to have a chance to interact, this is not your forum isnt it?
    Thursday, December 7, 2017 3:29 AM
  • and read the question carefully before commenting on the wrong thing. 

    How to run a windows defender scan and display scan results returned in command prompt in new window with the scan results as the title?

    Thursday, December 7, 2017 3:30 AM
  • You continue to say it fails without saying how it fails. We cannot see your screen.

    TITLE My new Windows title

    TITLE %scan_results%

    The scan results are obtainable from the ERRORLEVEL.  See the help for the scanner.

    also for help:

    TITLE /?


    \_(ツ)_/


    • Edited by jrv Thursday, December 7, 2017 3:36 AM
    Thursday, December 7, 2017 3:30 AM
  • and read the question carefully before commenting on the wrong thing. 

    How to run a windows defender scan and display scan results returned in command prompt in new window with the scan results as the title?

    Just change the windows title to display the scan results.   You cannot create a new window before you run the scan.  Run the scan first and then change the Window title.


    \_(ツ)_/

    Thursday, December 7, 2017 3:33 AM
  • How to run a windows defender scan and display scan results returned in command prompt in new window with the scan results as the title?

    Your question is ambiguous. What do you mean by "new window"? Do you mean a pop-up dialog message box, or the title of the console window? They are not the same thing. cmd.exe (batch) does not have a native command for displaying a pop-up dialog box, but it can change the console window title using the start command (when opening a new console) or the title command (as noted above).


    -- Bill Stewart [Bill_Stewart]

    Friday, December 8, 2017 4:10 PM