Hi, anyone knows what is the problem with this function, i believe i did
everything right, but it just does not open the cd-rom, maybe the
problem is in the part "InvokeVerb". Any help would be highly
appreciated.

def ejectDrives

  @wbem = WIN32OLE.new('WbemScripting.SWbemLocator')
  @a = @wbem.ConnectServer
  @b = @a.InstancesOf('Win32_LogicalDisk')
  cdroms = Array.new

  @b.each do | object |
    if object.Description =~ /cd/i
      cdroms << object.Name
    end
  end

  @shell = WIN32OLE.new('Shell.Application')

  cdroms.each do | name |

    @ej1 = @shell.NameSpace(name)
    @ej2 = @ej1.Self
    @ej3 = @ej2.InvokeVerb("Expu&lsar")

  end

end

This is another version using "WMPlayer.OCX" that actually work.

def ejectDrivesWMP

  @wmp = WIN32OLE.new('WMPlayer.OCX')

  @cdromCol = @wmp.cdromCollection
  @cdromCount = @cdromCol.Count

  i = 1
  while i <= @cdromCount
    @cdromCol.Item(i - 1).Eject
    i += 1
  end

end

-- 
Posted via http://www.ruby-forum.com/.