My code is as below
set log_file = Automation_log.log
call :main > %log_file%
exit /b
:main
call :main > %log_file% produces a syntax error.
You might wonder why I do not pass the log file name directly next to >, I did it because I've put the date and time in the file name and it would get customised.
By following the comment, below this is how my code looks
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
set log_file = Automation_Log__%mydate%_%mytime%.log
call :main > "%log_file%"
exit /b
:main
This too give error as The system cannot find the path specified.