Tech Sonu
Tech Sonu

Reputation: 13

How to capture logs in batch file

I want to write the script where I need to copy one folder from server on multiple servers (100) and same time When I run this batch file I want log file that on how many servers copy successfully completed with date & time.

I am able to copy the folder from one server to other using xcopy command but need help in capturing results.

Upvotes: 1

Views: 4198

Answers (1)

Stephen Connolly
Stephen Connolly

Reputation: 1639

Time /T

Will print the current time to the output stream

The easiest thing to do is to just capture all of the output from your batch file execution to a file. To do this, just use a command of the form:

MyBatchfile.Bat > Logfile.txt 2>&1

to pipe both stdout and stderr to a file.

Upvotes: 1

Related Questions