locked
BAT File error printing RRS feed

  • Question

  • Hello,

    Actually I am creating a BAT file for file rename operation and want to print the success and fail result on a text file as log.

    I want that if there is a failure in command it should not print the next echo result and simply ignore that.

    For example the following is my BAT file, in 2nd line it will print the error in "Result.log" if it has but the third line will also be printed which I dont want incase of error in 2nd line 

    echo Renaming server01 check page .......
    ren "\\server01\D$\page1" "page2" 2>>result.log
    echo page1 for server1 is renamed successfully on %date% %time% by %username% from %computername% >>result.log

    This is output

    The system cannot find the file specified.
    page1 for server1 is renamed successfully at Fri 10/12/2012 19:09:32.15 by ismailk from computer1

    Friday, October 12, 2012 2:38 PM

Answers