I'm currently writing a automated log by batch scripting and supposed to insert into a custom event using eventcreate.
log.txt ( inside contain information on the incidents )
eventcreate /id 101 /l application /t warning /so Something bad happened /d "%log%"
in this case, how am I able to create the event with the content in the log.txt ?
thanks..
If log.txt has a single line for each error you could try something like this in your bat file:
for /f "delims=" %%l in (log.txt) do eventcreate /id 101 /l application /t warning /so "Something bad happened" /d "%%l"
Otherwise if log.txt might contain multiple lines but you need to create only one event:
@echo off
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set eventtext=
for /f "delims=" %%l in ( test.txt) do set eventtext=!eventtext! %%l
eventcreate /id 101 /l application /t warning /so "Something bad happened" /d "%eventtext%"