Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to use eventcreate from a batch file to log the results of a file copy job (robocopy). What I'd really like to do is use the output of the file copy job as the description of the event (/D of createevent). The trouble is, there are multiple lines in the file copy output, and I've only been able to get one line into a local variable or a pipe command.

I've tried reading a local variable in from file, like

set /P myVar=<temp.txt

but it only gets the first line.

How can I write multiple lines to the description of an event from a batch file?

share|improve this question
    
Beware ^L (control-L or ASCII 12) is a formfeed character, ^J (control-I or ASCII 10) is a linefeed character. –  user176308 Jun 3 '13 at 12:43
add comment

1 Answer

up vote 0 down vote accepted

You have to parse the log and and change and CRLF to just LF (ctrl-l).

Here is an example:

EVENTCREATE /T ERROR /ID 1000 /l application /d "This is text^L this is line 2"
share|improve this answer
    
This doesn't work for me. It's all on one line in the event log with the ^L printed out literally. –  Adam J.R. Erickson Apr 30 '10 at 21:14
    
hmm I tested this out on windows 7 what OS are you running this on? Did you type ctrl-l or ^L? –  Jim B May 1 '10 at 3:13
    
I think I copied and pasted. Hitting Ctrl-l did the trick. How would I get that into a batch file, though? –  Adam J.R. Erickson May 10 '10 at 21:27
    
Using just native tools it's challenging. The simplest way would be to use copy con to type the character into the file then use notepad to finish the batch file. –  Jim B May 12 '10 at 13:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.