5

I have given a bat file that I should run on development server which does some updates.

It has multiple commands and I would like to keep the results in txt file.

Should I add after each command >> result.txt or I can add it somewhere in the end of bat file and everything will be written in that?

1 Answer 1

4

You have four options:

  • Run the batch file at the command line like: myBat.bat >> outPut.txt

  • Script the above in another batch file and run that

  • Insert the >> after each command ( Note: the >> appends to file, while > overrides existing text output file)

  • Enclose all relevant lines in parentheses and script >> result.txt once at the end of the script

Sign up to request clarification or add additional context in comments.

6 Comments

4.) enclose all relevant lines in parantheses and do >>result.txt only once.
^ Also that! I won't add to my answer so you can get any up votes.. probably many many more options as well
feel free to use it for your answer. Three solutions from you, one from me. It's you who deserves the upvotes ;)
Alternatively, instead of >>, find a windows version of the unix tee utility to both see the output and redirect it to capture results.
@PA Good tip but I think the OP is talking about windows only??
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.