Herman - This is the clip, in the rough and not tested this morning, from the initial statements I used to start Amibroker in a batch script. I got this help from Dingo and basically clipped and pasted and it works. I haven't tested it in a while but looks like that's the direction you want to go in that it gives you the ABlist. Would look for concurrence from Dingo, TJ, or others who are knowledgeable in OLE work?
Hope this helps
Joe
// Holdings ODBC Work Generates an Equity Curve Representing Shares Held
// Test to see if Amibroker is Open
// If so, do nothing
// If not, start Amibroker
// Create a Shell Object
var WinMgM = GetObject("WinMgmts://localhost")
var WSH = WScript.CreateObject("WScript.Shell")
// We have not looked for or found Amibroker yet, record this below
ABFound = false
// Get a list of Amibroker instances currently running (which maybe none)
var ABList = WinMgM.ExecQuery ("select * from Win32_Process where name='Broker.exe'")
// go through the list
var e = new Enumerator(ABList);
----- Original Message -----
Sent: Monday, October 06, 2008 9:18 AM
Subject: [amibroker] How to detecting second AmiBroker Instance
I am developing a system that involves simple OLE/J-Scripts. It happens that due to coding bugs I end up with a second instance of AmiBroker. When this happens I can only detect this using the windows task manager. Several times now i have wasted hours trying to find out why my code didn't export proper reports only to find out that a second AB was running. When I closed everything down everything works fine.
Would anyone know how to detect from (preferable) AFL, or J-Script, whether AB is already running?
TIA,
herman