Ruby.exe crashing with WIN32OLE WMI example?

Hi everyone,

I’m trying to do some WMI stuff with Ruby. I found this simple
example somewhere. It works – until the program exists that is.
Then Windows pops up a “ruby.exe - Application Error” message box due
to inappropriate memory access.

require ‘win32ole’

mgmt = WIN32OLE.connect(‘winmgmts:\\.’)
mgmt.InstancesOf(“win32_process”).each{ |proc|
puts proc.name
}
pause

Does anyone know how to solve the problem? I’m running “ruby 1.8.0
(2003-08-04) [i386-mswin32]” on Windows 2000.

Regards,
Yonatan