locked
How do I suppress output from a batch file? RRS feed

  • Question

  • I have:

    @ECHO OFF

    ....

    DEL /s /q .\MyTempDirectory

    and at this point all file names being deleted are displayed in the command window.

    I would prefer not to see these file names.


    Pete Grant
    Saturday, December 25, 2010 12:51 PM

Answers

  • Better yet, if you don't want to deal with a file just redirect to the NUL device.  The output will disappear into a cyber black-hole, never to be seen by mortal man again.

    EX: 

    MYBAT.BAT >NUL

    • Marked as answer by Leon Liu - MS Wednesday, January 19, 2011 3:08 AM
    Saturday, December 25, 2010 3:07 PM
  • On 12/25/2010 7:51 AM, PeteClimbs wrote:
    > I have:
    >
    > @ECHO OFF
    >
    > ....
    >
    > DEL /s /q .\MyTempDirectory
    >
    > and at this point all file names being deleted are displayed in the
    > command window.
    >
    > I would prefer not to see these file names.
    >
     
    Use the '>' and redirect out put to a file.
     
    <http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true>
     
    Go to the Command Prompt and do it with the DIR command to see how it works.
     
    • Marked as answer by Leo Huang Friday, December 31, 2010 7:47 AM
    Saturday, December 25, 2010 1:02 PM

All replies

  • On 12/25/2010 7:51 AM, PeteClimbs wrote:
    > I have:
    >
    > @ECHO OFF
    >
    > ....
    >
    > DEL /s /q .\MyTempDirectory
    >
    > and at this point all file names being deleted are displayed in the
    > command window.
    >
    > I would prefer not to see these file names.
    >
     
    Use the '>' and redirect out put to a file.
     
    <http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true>
     
    Go to the Command Prompt and do it with the DIR command to see how it works.
     
    • Marked as answer by Leo Huang Friday, December 31, 2010 7:47 AM
    Saturday, December 25, 2010 1:02 PM
  • Better yet, if you don't want to deal with a file just redirect to the NUL device.  The output will disappear into a cyber black-hole, never to be seen by mortal man again.

    EX: 

    MYBAT.BAT >NUL

    • Marked as answer by Leon Liu - MS Wednesday, January 19, 2011 3:08 AM
    Saturday, December 25, 2010 3:07 PM