send result to a txt based log file

Posted on 2011-10-10
Last Modified: 2012-05-12
Dear all expertise,

Right now I want to create a .bat file and execute it while export the result to a txt file, how can I do the export of result to a txt file ?

Question by:marrowyung
    LVL 6

    Expert Comment

    Try to launch your Batch fril fomr command line, add this syntax:

    Mybatfile.bat 2>c:\temp\ERROR.TXT >c:\TEMP\LOG.txt
    LVL 6

    Expert Comment

    oh my god, I typed too fast !
    I meant "Try to launch your Batch file from a command line" of course.

    This syntax will redirect error canal(2) in error.txt file and output canal (1) in Log.txt file.
    LVL 10

    Accepted Solution

    As an additon to Gerald26's postings, it is possible to redirect any errors to the same file as the main output (stdErr and stdOut).

    mybatfile.bat > c:\temp\log.txt 2>&1

    The 2>&1 tells it to put the errors into the first log file.
    LVL 6

    Assisted Solution

    And finally you can use

    Mybatfile.bat >> C:\temp\log.txt 2>&1 to add new content to old log file each time you start your batch program without erasing previous output.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Several part series to implement Internet Explorer 11 Enterprise Mode
    Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now