I am trying to open an application: Bluezone Mainframe Emulator to take a stab at automating some mainframe processes with Ruby.
I run into an issue when trying to open the application with Win32ole. Here is my code so far:
require 'win32ole'
class BluezoneRunner
attr_reader :app
def initialize
@type = WIN32OLE_TYPE.new('BZWhll 7.1 Type Library', 'WhllObj')
@app = WIN32OLE.new('BZWhll.WhllObj')
end
def visible=(is_visible)
@app.visible = is_visible
end
def close
@app.Quit
end
end
The script fails when assigning the app object with this error:
Uncaught exception: failed to create WIN32OLE object from `BZWhll.WhllObj'
HRESULT error code:0x80040154
Class not registered
C:/RubyProjects/mksta-sandbox/bluezone-automation/run_ole.rb:9:in `initialize'
C:/RubyProjects/mksta-sandbox/bluezone-automation/run_ole.rb:9:in `new'
C:/RubyProjects/mksta-sandbox/bluezone-automation/run_ole.rb:9:in `initialize'
C:/RubyProjects/mksta-sandbox/bluezone-automation/bluezone_runner.rb:3:in `new'
C:/RubyProjects/mksta-sandbox/bluezone-automation/bluezone_runner.rb:3:in `<top (required)>'
I am currently running Windows 10 64 bit, Ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]. The application i am trying to run sits in C:\Program Files (x86)\BlueZone\7.1.
Any help on this error would be great!
As it turns out, the error in my case was caused by using a 64 bit version of Ruby.
To solve this issue, use a 32 bit (X86) version of Ruby to run this code.