Handling 2 or more program instances of windows program via ruby on windows

105 Views Asked by At

Ok, so. Thank you for reading this.

I is very easy to handle multiple instances of for example excel in ruby, simply by defining two variables:

require 'win32ole'

excel1 = WIN32OLE.new('Excel.Application')
excel2 = WIN32OLE.new('Excel.Application')

...magic happens aaaaand it works just fine. (Excel probably support multiple instances by default)

Lets move on other example. (after many hours of googling) I found a way how to run two separate instances of program which do not support it (at least ruby is not working on them as it is working with excel) by creating *.bat file (or typing it in cmdline):

start "BrioQry" "C:\Program Files (x86)\Brio\Brio8\Client\Program\brioqry.exe" "C:\samefiletoload.bqy" /e %1
start "BrioQry" "C:\Program Files (x86)\Brio\Brio8\Client\Program\brioqry.exe" "C:\samefiletoload.bqy" /e %2

I have no idea what the /e and %1 and %2 is doing (% is probably parameter) but it is working just fine. Yes, the files are same. And I can get some info about that processes via winmgmts

require 'win32ole'
mywmi = WIN32OLE.connect("winmgmts:\\\\.")

So, my questions are:

1) if it is possible to run separate instances (of programs which do not support it) by adding some kind of parameter to WIN32OLE.run()

2) if it is possible to connect to already running processes (started via cmdline) by WIN32OLE.connect method

3) if i am not crazy by trying to acomplish this

4) if there is some other way to do this in ruby or in python

(Yes, I want then work with that application)

Thank you!!!

0

There are 0 best solutions below