Hi all

I'm a beginner at ruby, so correct me if I'm doing something stupid.

I have created a method that reads a property from a windowsinstaller
table. (msi-package).

I have a list with paths to msi-packages, its 238 msi-packages that I'm
searching throe.
If i searching all the 238 files it eats a lot of memory (240 mb). And
21 packages fails to be read.
If i split the list in two it work without any problem, all the files
works.

I wonder if i have write my method in a bad way.

Any ideas ?

Method:

def GetProperty(msiPath, property)
    begin
        require 'win32ole'
        msiInstaller = WIN32OLE.new('WindowsInstaller.Installer')
        db = msiInstaller.OpenDatabase(msiPath, 0)
        view = db.OpenView("SELECT Value FROM Property WHERE Property =
'#{property}'")
        view.Execute()
    rescue RuntimeError
        return "ERROR"
    end
        record = view.Fetch()
        if record != nil then
            return record.StringData(1)
        else
            return 0
        end
end

GetProperty("\\path\to\msi\package.msi", "ALLUSERS")

If the property don't exist it return 0, if the msi-package don't exist
it return error, or if any other error message appear. If everything
work it return the value of ALLUSERS in the property-table of the
msi-packge.

If i inactivate the method the script doesn't use so much memory.

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