You have to store the first message into a variable and then use it in the last redirection to file.
To use your code it would look like this:
@echo off
set "log=C:\t\so\batch\log.log"
set "message=Starting Program 1 ... "
call Program1.cmd
if %ERRORLEVEL%==1 (
echo %message% Error. >> %log%
) else (
echo %message% Success. >> %log%
)
Edit In my script above you may lose the logging information if something goes seriously wrong with the called script.
You could do it like this:
@echo off
set "log=C:\t\so\batch\log.log"
echo | set /p message="Starting Program 1 ... " >> %log%
call Program1.cmd
if %ERRORLEVEL%==1 (
echo Error. >> %log%
) else (
echo Success. >> %log%
)
The /p
switch:
The /P switch allows you to set the value of a variable to a line of
input entered by the user. Displays the specified promptString before
reading the line of input. The promptString can be empty.
Note: here the message is just a dummy variable.
There is a complex answer from dbehham on this topic.