in reply to Event viwer activities since the last shutdown.
Provided the EventLog contains somewhere the error number in its messages, the following should work (adapted from an example in the docs):
use Win32::EventLog; $handle=Win32::EventLog->new("System", $ENV{ComputerName}) or die "Can't open Application EventLog\n"; $handle->GetNumber($recs) or die "Can't get number of EventLog records\n"; $handle->GetOldest($base) or die "Can't get number of oldest EventLog record\n"; while ($x < $recs) { $handle->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ, $base+$x +, $hashRef) or die "Can't read EventLog entry #$x\n"; Win32::EventLog::GetMessageText($hashRef); my $message="Entry " . $x . ":" . $hashRef->{Source} . " ** " . $h +ashRef->{Message}; print "$message\n" if $message=~/6005/; $x++; }
We will leave it as an exercise for the reader (and also because I have not the faintest idea how to do it) to check the date and time of the message so you only display the errors since the last reboot.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Event viwer activities since the last shutdown.
by blackadder (Hermit) on Aug 15, 2003 at 16:00 UTC | |
by CountZero (Bishop) on Aug 15, 2003 at 21:10 UTC |