Jump to content

Write to Windows event log: Difference between revisions

Line 196:
return char_count
}</lang>
=={{header|AWK}}==
<lang AWK>
# syntax: GAWK -f WRITE_TO_WINDOWS_EVENT_LOG.AWK
BEGIN {
write("INFORMATION",1,"Rosetta Code")
exit (errors == 0) ? 0 : 1
}
function write(type,id,description, cmd,esf) {
esf = errors # errors so far
cmd = sprintf("EVENTCREATE.EXE /T %s /ID %d /D \"%s\" >NUL",type,id,description)
printf("%s\n",cmd)
if (toupper(type) !~ /^(SUCCESS|ERROR|WARNING|INFORMATION)$/) { error("/T is invalid") }
if (id+0 < 1 || id+0 > 1000) { error("/ID is invalid") }
if (description == "") { error("/D is invalid") }
if (errors == esf) {
system(cmd)
}
return(errors)
}
function error(message) { printf("error: %s\n",message) ; errors++ }
</lang>
{{out}}
<pre>
EVENTCREATE.EXE /T INFORMATION /ID 1 /D "Rosetta Code" >NUL
</pre>
 
=={{header|Batch File}}==
477

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.