Batch Script to Email Event Log Warnings / Alerts

I want to create a batch script that will email me (via our exchange smtp) when a warning or error is logged in event viewer.

I found this post http://www.experts-exchange.com/Operating_Systems/Q_21399340.html ; which has this script.

____________________________________________________________________________________________
@echo off
setlocal ENABLEDELAYEDEXPANSION

dumpel -s \\servername -l system -d 1 -m Eventlog -e 6008|find "6008">alert.log
if not errorlevel 1 smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log
____________________________________________________________________________________________

is there a way i can modify this script to do what i want?

Thanks
Phil
LVL 2
detox1978Asked:
Who is Participating?
 
CowboyJeeperCommented:
The following code will filter for all the errors in the past day and mail as it did before.

dumpel -l system -c -d 1 |find ",1," > c:\aalert.txt
if not errorlevel 1 smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log
0
 
SteveGTRCommented:
You could schedule this task to run daily:

@echo off

if exist "ALERT.LOG" del "ALERT.LOG" >NUL

REM ** Change server as needed
for /f "delims=" %%a in ('dumpel -s \\server -l system -d 1') do call :PROCESS "%%a"

REM ** Change email info as needed
if exist "ALERT.LOG" smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log

goto :EOF

:PROCESS

for /f "tokens=4" %%a in ('echo %~1') do if /i "%%a" LEQ 2 call :DUMPIT %1

goto :EOF

:DUMPIT

echo %~1>>ALERT.LOG

Good Luck,
Steve
0
 
detox1978Author Commented:
thanks for the scripts....

I dont have smtpsend, do you know of a free commercial version?


Thanks
phil
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
SteveGTRCommented:
I googled it and came up with a number of links. Here is one:

http://www.naughter.com/smtpsend.html
0
 
detox1978Author Commented:
smtpsend is not free for comercial use, is there a way to use exchanges' smpt?
0
 
SteveGTRCommented:
I don't know.
0
 
detox1978Author Commented:
will post in the exchange section...
0
 
neteducationCommented:
The Microsoft Exchange Resource Kit contains a program, SENDMAIL.EXE, which is a 32-bit command line  utility to send mail messages and file attachments. This program is also available in the Microsoft Mail Resource Kit.

0
 
detox1978Author Commented:
cheers, will look into
0
 
detox1978Author Commented:
thanks for the links and tips....

looked into and it seemed like a lot of work.

ended up buy Selm from GFI.


P
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.