flaggkort
asked on
DOS batch file to copy and generate a log file only if there's an error
I have a batch file I've written that copys a file every night over our VPN from each of our stores to the server. The problem is that if there's an error then I don't know it. Is there a way using a switch or DOS to generate a log.txt file only if there's an error such as if the VPN were down? Below is an example of my file at present.
copy "\\192.168.2.121\Title Loan Professional Plus\database\titleloan2k_ be.mdb" N:\Athens /y /z
copy "\\192.168.2.121\Title Loan Professional Plus\database\titleloan2k_
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
For some reason the second answer didn't work but this one worked perfectly. Thanks!
This might look neater:
copy /y /z "\\192.168.2.121\Title Loan Professional Plus\database\titleloan2k_
if not %errorlevel% equ 0 (
echo %date% %time% Error occured copying titleloan2k_be.mdb >>error.log
)