Write to Windows event log: Difference between revisions

Content added Content deleted
m (→‎{{header|Batch File}}: Changed to the proper way to hide output (>NUL 2>&1))
Line 238: Line 238:
If you do not want the command to display its result or errors...
If you do not want the command to display its result or errors...
<lang dos>@echo off
<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 ERROR /id 123 /l SYSTEM /so "A Batch File" /d "This is found in system log." >NUL 2>&1
EventCreate /t WARNING /id 456 /l APPLICATION /so BlaBla /d "This is found in apps log" 2>NUL>NUL
EventCreate /t WARNING /id 456 /l APPLICATION /so BlaBla /d "This is found in apps log" >NUL 2>&1
::That "2>NUL>NUL" trick actually works in any command!</lang>
::That ">NUL 2>&1" trick actually works in any command!</lang>


'''NOTE:''' This will (...or might) not work if you do not have administrator privileges.
'''NOTE:''' This will (...or might) not work if you do not have administrator privileges.