Write batch file results to log




















The second command cleans up the directory by deleting old copies. When I run the batch, by either calling it from the remote server, or by double clicking it straight away, the cmd window opens and runs the clean up.

It will create a file in the directory called 'logfile. The process that calls this batch file from the remote server is scheduled, and I want to see what happened when this was called later.

How do I get the results to write to the log file. I imagine it should look very similar it not the same as what the cmd window pops opens and shows. I reference this other post: Redirecting Output from within Batch file. I put a pause in the file to capture the cmd window. I am looking to capture this information and of course any errors that occur.

Maybe this is the wrong approach? You could use following batch code to redirect stdout and stderr to a log file. See also the Microsoft TechNet article Using command redirection operators. The log file is created new only if not already existing. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Rgds, Rains. Share Flag.

All Answers. Collapse -. Redirect the output. Back to Software Forum. Start or search. Check the permissions on the file. I would assume if you can create a file, you would have write access. What you have works perfectly fine. I want all messages, just as they appear in the DOS-Windows. Note the double arrows, instead of single. This works in win Thanks, I tried that, but with no luck. The log file will be created, but it is always empty.

I even made a batch file that produces an error, but not even that is logged. You need to be a member in order to leave a comment. Sign up for a new account in our community. It's easy! Already have an account?

Sign in here. Existing user? How to log the results of a DOS batch file? Facebook Twitter.



0コメント

  • 1000 / 1000