logging the results of a batch file
Hi,
We have a batch file which runs weekly at night that updates anti virus software on client computers. What is the syntax to output the results of this or any other batch file to a simple text file. Thanks.
Windows Forum
Hi,
We have a batch file which runs weekly at night that updates anti virus software on client computers. What is the syntax to output the results of this or any other batch file to a simple text file. Thanks.
by vinnyd
Here is a sample of a batch file I use that sends the starndard output to a text file.
net start "Microsoft Exchange Event Service" > C:\strtexch.log
net start "Microsoft Exchange Internet Mail Service" >> C:\strtexch.log
The > sign sends theoutput from the net start command into the file called c:\strtexch.log.
The > by itself creates the file or writes over an existing file.
The >> you see on the 2nd line of the sample appends the test to the log file.
by donalconlon
by beermonster
Hi,
Just a quick addition to the last respondent's comments. When the command interpreter echoes to the screen or a file it does so using one of two 'streams' - standard out and error out. You may find that, although the > and >> will work for the majority of the time, occasionally a command (such as a net use etc) will fail and the output will NOT be logged to your batch file (you can test this by typing "net stop nonexistentservice >> mylog.txt" - obviously without the quotes - you will see that the logfile is empty afterwards although an error was displayed onscreen). this is because the error message is being passed to a different output stream (the error out) which is not picked up by the > and >> redirection methods. To get round this use 2>&1 eg
net stop myservice 2>&1 >> mylog.txt
Hope this helps
by donalconlon
by donalconlon
This discussion is closed to new replies.
Sort by Trending