<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>Windows Perl Scripting Forums &#187; Topic: Problems with Win32::EventLog</title>
<link>http://www.roth.net/forums/</link>
<description>Windows Perl Scripting Forums &#187; Topic: Problems with Win32::EventLog</description>
<language>en</language>
<pubDate>Sun, 19 May 2013 11:09:41 +0000</pubDate>

<item>
<title>Dave on "Problems with Win32::EventLog"</title>
<link>http://www.roth.net/forums/topic.php?id=177#post-413</link>
<pubDate>Wed, 26 Sep 2007 19:28:58 +0000</pubDate>
<dc:creator>Dave</dc:creator>
<guid isPermaLink="false">413@http://www.roth.net/forums/</guid>
<description>&#60;p&#62;You have run into a problem that I write about in my chapter 5 of my second book, &#60;em&#62;Win32 Perl Scripting: The Administrator&#38;#39;s Handbook&#60;/em&#62;,&#38;nbsp;(&#60;a href=&#34;../books/handbook/&#34;&#62;http://www.roth.net/books/handbook/&#60;/a&#62;). What you are seeing is by design of the Event Log. &#60;br /&#62;When data is stored in an event they are stored as arrays of strings. Also stored in the event is a message ID number and an event message provider. The provider is typically a DLL that contains a message table containing messages each with its own ID.When you create an event you have to identify which provider (message table; this is the &#38;quot;Event Source&#38;quot;) to use and supply the message ID (which message within the message table; this is the &#38;quot;Event ID&#38;quot;). These mesasges contain special symbols that are swapped out for the array data you specified when you created the event. &#60;/p&#62;
&#60;p&#62;Details on how this all works: &#60;a href=&#34;http://msdn2.microsoft.com/en-us/library/aa363681.aspx&#34;&#62;http://msdn2.microsoft.com/en-us/library/aa363681.aspx&#60;/a&#62; &#60;br /&#62;For a Perl script all you need to use is &#60;a href=&#34;../perl/packages/Win32-EventLog-Message.ppd&#34;&#62;Win32::EventLog::Message&#60;/a&#62;. You can download it from our FTP site or install it from our package repository: &#60;/p&#62;
&#60;p&#62;&#60;code&#62;perl ppm.pl -install &#60;a href=&#34;../perl/packages/win32-eventlog-message.ppd&#34;&#62;http://www.roth.net/perl/packages/win32-eventlog-message.ppd&#60;/a&#62;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;How it works: &#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;Your script registers an event log source&#60;/li&#62;
&#60;li&#62;You specify an event ID and supply string data when creating an event.&#60;/li&#62;
&#60;li&#62;Life is good.Note that only machines that have the Win32::EventLog::Message installed and registered will be able to display the nice message text. Otherwise it will come out as you noted.&#60;/li&#62;
&#60;/ol&#62;
Look at &#60;a href=&#34;../perl/scripts/scripts.asp?UpTimeMon.pl&#34;&#62;http://www.roth.net/perl/scripts/scripts.asp?UpTimeMon.pl&#60;/a&#62;&#38;nbsp;for an example of how this all works.
&#60;/p&#62;</description>
</item>
<item>
<title>ebm on "Problems with Win32::EventLog"</title>
<link>http://www.roth.net/forums/topic.php?id=177#post-410</link>
<pubDate>Wed, 26 Sep 2007 12:53:30 +0000</pubDate>
<dc:creator>ebm</dc:creator>
<guid isPermaLink="false">410@http://www.roth.net/forums/</guid>
<description>&#60;p&#62;Let me try this again didn&#38;#39;t realize it added html... to it. sorry.&#60;/p&#62;
&#60;p&#62;&#38;nbsp;I&#38;rsquo;ve been trying to use Win32::EventLog for a script on my win2k server and seem to have a problem when it generates an Event to the Event Viewer.&#38;nbsp; The Event contains some extra garbage and I&#38;rsquo;m not sure how to generate the event without getting this garbage included in it.&#60;/p&#62;
&#60;p&#62;Here&#38;rsquo;s the generated event message:&#60;br /&#62;Event Type:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; Error&#60;br /&#62;Event Source:&#38;nbsp;&#38;nbsp;&#38;nbsp; Weekly Report Script&#60;br /&#62;Event Category:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; None&#60;br /&#62;Event ID:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; 100&#60;br /&#62;Date:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; 09/26/2007&#60;br /&#62;Time:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; 12:01:32 PM&#60;br /&#62;User:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; N/A&#60;br /&#62;Computer:&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; LVEPL3LX620&#60;br /&#62;Description:&#60;br /&#62;The description for Event ID ( 100 ) in Source ( Weekly Report Script ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: This is a Test Error......&#60;/p&#62;
&#60;p&#62;I only want the description to contain the message &#38;ldquo;This is a Test Error&#38;hellip;..&#38;rdquo;&#60;/p&#62;
&#60;p&#62;Here&#38;rsquo;s the code.&#38;nbsp; Can you please tell me what I&#38;rsquo;m doing wrong. &#38;nbsp;&#60;/p&#62;
&#60;p&#62;use Win32::EventLog;&#60;br /&#62;my $Type = &#38;quot;ERROR&#38;quot;;&#60;br /&#62;my $IDNum = 100;&#60;br /&#62;my $Description = &#38;quot;This is a Test Error.....&#38;quot;;&#60;/p&#62;
&#60;p&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; chomp( $Type, $IDNum, $Description );&#60;/p&#62;
&#60;p&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; my %Event = (&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; Length&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; NULL,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; RecordNumber&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; NULL,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; TimeGenerated&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; NULL,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; EventID&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; $IDNum,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; Category&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; NULL,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; Source&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; &#38;quot;Weekly Report Script&#38;quot;,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; Strings&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; =&#38;gt; $Description,&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; );&#60;/p&#62;
&#60;p&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; if ( uc($Type) eq &#38;quot;ERROR&#38;quot; ) {&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $Event{&#38;#39;EventType&#38;#39;} = EVENTLOG_ERROR_TYPE;&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; }&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; elsif ( uc($Type) eq &#38;quot;WARN&#38;quot; ) {&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $Event{&#38;#39;EventType&#38;#39;} = EVENTLOG_WARNING_TYPE;&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; }&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; elsif ( uc($Type) eq &#38;quot;INFO&#38;quot; ) {&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $Event{&#38;#39;EventType&#38;#39;} = EVENTLOG_INFORMATION_TYPE;&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; }&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; elsif ( uc($Type) eq &#38;quot;AUDIT&#38;quot; ) {&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $Event{&#38;#39;EventType&#38;#39;} = EVENTLOG_AUDIT_SUCCESS;&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; }&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; else {&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $Event{&#38;#39;EventType&#38;#39;} = EVENTLOG_AUDIT_FAILURE;&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; }&#60;/p&#62;
&#60;p&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; my $LogEvent = Win32::EventLog-&#38;gt;new(&#38;quot;Application&#38;quot;)&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; or die &#38;quot;Can&#38;#39;t open Application Event Log to enter $Description\n&#38;quot;;&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $LogEvent-&#38;gt;Report( \%Event )&#38;nbsp; or die($!);&#60;br /&#62;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; $LogEvent-&#38;gt;Close();&#60;/p&#62;</description>
</item>
<item>
<title>ebm on "Problems with Win32::EventLog"</title>
<link>http://www.roth.net/forums/topic.php?id=177#post-409</link>
<pubDate>Wed, 26 Sep 2007 12:48:24 +0000</pubDate>
<dc:creator>ebm</dc:creator>
<guid isPermaLink="false">409@http://www.roth.net/forums/</guid>
<description>&#60;br /&#62;</description>
</item>

</channel>
</rss>
