[Win32utils-devel] Can't write to "Windows PowerShell" source with win32-eventlog

Daniel Berger djberg96 at gmail.com
Tue Nov 27 20:15:05 EST 2007

Hi all,

Tim Uckun reported, and I've confirmed, that you can't write to the 
Windows PowerShell event source for some reason.

Tim thought it might be because of the space in the name, but my attempt 
to quote it did not seem to help.

In order to follow along, install PowerShell, create the foo.dll using 
the foo.mc file in the 'test' directory, and try the following code:

require 'win32/eventlog'
include Win32

    :source                => 'Windows PowerShell',
    :key_name              => 'foo',
    :category_count        => 2,
    :event_message_file    => 'foo.dll',
    :category_message_file => 'foo.dll'

EventLog.open('Windows PowerShell') do |log|
       :source     => "foo",
       :event_type => EventLog::WARN,
       :category   => "0x00000002L".hex,
       :event_id   => "0x00000003L".hex,
       :data       => "I'm warning you!"

As Tim mentioned, this doesn't raise an error. It just doesn't seem to 
do anything.

Any ideas? Anything special about the Windows PowerShell source?

In unrelated news, my attempts to replace RegCreateKey with 
RegCreateKeyEx in EventLog.add_event_source failed. Or shouldn't I 
bother with it?



More information about the win32utils-devel mailing list