Yonatan of yonatan_avraham at hotmail.com humbly asked:
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.
I cannot solve it but I can compare it w mine.
c:\family\ruby>ver
Microsoft Windows XP [Version 5.1.2600]
c:\family\ruby>ruby -wv a1.rb
ruby 1.8.1 (2003-12-05) [i386-mswin32]
a1.rb:4: warning: class variable ARGV of Object is overridden by WIN32OLE
System Idle Process
System
smss.exe
csrss.exe
winlogon.exe
services.exe
lsass.exe
svchost.exe
svchost.exe
svchost.exe
svchost.exe
spoolsv.exe
cisvc.exe
sscansvc.exe
ntrtscan.exe
snmp.exe
tmlisten.exe
winvnc.exe
Fast.exe
OfcDog.exe
explorer.exe
TaskSwitch.exe
tfswctrl.exe
VxTaskbarMgr.exe
PccNTMon.exe
jusched.exe
ctfmon.exe
EMEDTRAY.EXE
getright.exe
WinKey.exe
wweb32.exe
soffice.exe
OUTLOOK.EXE
svchost.exe
opera.exe
cidaemon.exe
wisptis.exe
cmd.exe
wmiprvse.exe
ruby.exe
Now, I have a q to the cool win32ole maintainer: why the argv override?
Regards,
Yonatan
kind regards -botp
Regarding Botp’s configuration using Windows XP…
“Peña, Botp” botp@delmonte-phil.com wrote in message news:1030AB5FAD0A3847B7B1F7B93332AFB501E181F0@bgmail00.delmonte-phil.com…
Yonatan of yonatan_avraham at hotmail.com humbly asked:
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.
^^^^^^^^^^^^
I cannot solve it but I can compare it w mine.
c:\family\ruby>ver
Microsoft Windows XP [Version 5.1.2600]
^^^^^^^^^^
…I just installed Ruby 1.8 on an Windows XP box and the WMI example
works fine. I then installed it on another Windows 2000 box and the
WMI example crashes. Any ideas?
Thanks,
Yonatan
“yonatan” yonatan_avraham@hotmail.com skrev i en meddelelse
news:37fcf3c0.0401060555.7ab8a404@posting.google.com…
Regarding Botp’s configuration using Windows XP…
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.
…I just installed Ruby 1.8 on an Windows XP box and the WMI example
works fine. I then installed it on another Windows 2000 box and the
WMI example crashes. Any ideas?
The fact that it crashes on application exit seems to indicate a problem
with reference counting where an object is being deleted after it has
already been deleted once. The Ruby GC will collect all live objects on exit
and this is why the problem shows up here. Only a suggestion of course.
Why it works on one OS and not on another is difficult answer.
Also it doesn’t answer why a reference count error might happen in the first
place.
Except if there is a bug in either the Ruby impl. or in the WMI COM objects
implementation.
Regards
MikkelFJ
yonatan wrote:
…I just installed Ruby 1.8 on an Windows XP box and the WMI example
works fine. I then installed it on another Windows 2000 box and the
WMI example crashes. Any ideas?
No, but FWIW, I’ve seen this very thing myself – so at least you know
you’re not crazy … or we both are.
···
–
Chris
http://clabs.org