@echo off
if (%1)==(0) goto skipme
echo -------------------------------------------------------------------------- >>logerror.txt
echo ^|%date% -- %time%^| >>logerror.txt
echo -------------------------------------------------------------------------- >>logerror.txt
script 0 2>> logerror.txt
:skipme
at the beginning, the lines that suppose to show time and date and --------- does not work, with no errors
This thread looks very familiar. Feel like I got on a merry-go-round on Groundhog Day and can't get off.
Actually, the lines at the beginning are NOT coded to show you the date and time as you are redirecting the
echo output to a file. In fact, the
echo statements work exactly as you coded them. If you want the date and time displayed on the console, lose the redirection. If you want both redirection and console output you'll need to code both outputs. I already posted in your other thread that you cannot send the same output to two different streams in the same instruction.
Just guessing, but is your batch file named
script? If so the reference to
script in the file is a recursive transfer of control back to the running file. Not only can this create problems, it is not best practice. What are you trying to do? Your file has a check for the first command line parameter which skips over the redirection. Why?
How did you manage to turn something so simple into a Rube Goldberg contraption?