Write to Windows event log: Difference between revisions

Added Batch File
m (→‎{{header|REXX}}: removed STYLE from the PRE html tag.)
(Added Batch File)
Line 193:
return char_count
}</lang>
 
=={{header|Batch File}}==
The "EventCreate" command does the task.
<lang>@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>
{{Out}}
<pre>>EventLog.BAT
 
SUCCESS: An event of type 'ERROR' was created in the 'SYSTEM' log with 'A Batch File' as the source.
 
SUCCESS: An event of type 'WARNING' was created in the 'APPLICATION' log with 'BlaBla' as the source.
 
></pre>
If you do not want the command to display its result or errors...
<lang>@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
::That "2>NUL>NUL" trick actually works in any command!</lang>
 
=={{header|BBC BASIC}}==
535

edits