Write to Windows event log: Difference between revisions

Added Syntax highlighting in Batch File solution
(Added Batch File)
(Added Syntax highlighting in Batch File solution)
Line 196:
=={{header|Batch File}}==
The "EventCreate" command does the task.
<lang dos>@echo off
EventCreate /t ERROR /id 123 /l SYSTEM /so "A Batch File" /d "This is found in system log."
EventCreate /t WARNING /id 456 /l APPLICATION /so BlaBla /d "This is found in apps log"</lang>
</lang>
{{Out}}
<pre>>EventLog.BAT
Line 209 ⟶ 208:
></pre>
If you do not want the command to display its result or errors...
<lang dos>@echo off
EventCreate /t ERROR /id 123 /l SYSTEM /so "A Batch File" /d "This is found in system log." 2>NUL>NUL
EventCreate /t WARNING /id 456 /l APPLICATION /so BlaBla /d "This is found in apps log" 2>NUL>NUL
535

edits