If you simply want to redirect all your logs to a Log.txt file, use the following script and save it as a ".bat" file.@echo off SET LOGFILE="Log.txt" call :Logit >> %LOGFILE% exit /b 0 :Logit ECHO ########This is a Log######################################Now Run the batch file that you have created. You will see the logs in a Log.txt file.
If you want to Create the Log file with date time stamp, then use the following script and save it as a batch file.
@echo off SET LOGFILE="LOG-%date%-%time:~0,2%-%time:~3,2%-%time:~6,2%.txt" call :Logit >> %LOGFILE% exit /b 0 :Logit ECHO ########This is a Log######################################This will create the LOG-YYYY-MM-DD-HH-MM-SS.txt file for you.
Redirecting Logs in Windows Batch File to a Log File
Leave a reply