Launching Amibroker 32bit in Automation OLE

I have both 32bit and 64bit Amibroker installed on my system. Whenever I run the javascript, this message pop up.
I suspect that this statement launches the 64bit version.
ab = new ActiveXObject("Broker.Application");

Is there a way to select the 32bit version ?
Thanks in advance.

You haven't provided more info on how you're running the javascript, but a simple test is as follows:

if you call Cscript.exe from cmd, it'll by default invoke the 64bit version.
To explicity invoke the 32bit, use its full path,

c:\Windows\SysWOW64\cscript.exe //E:JScript //nologo "test.js"

EDIT similarly, WScript.exe is the GUI equivalent of CScript.

Try this and let us know.

Thanks for your reply.
I right-click on the javascript file icon and select Open with Microsoft Window Based Script Host and that pop up message appear.

However, after my post, I launch the javascript from Amibroker Tools and there is no pop up message.

Possible to select the 32bit in the AcvtiveXObject ?

@Peter2047 this issue has been described by Tomasz in this article:

Running OLE automation scripts with 32- and 64-bit versions of AmiBroker

And additionally:

I was googling for a solution and this page showed up and I didn't get the message! :disappointed:

Hehe, I said the same thing :slight_smile: but double clicking in windows can be self-destructive :smiley:

Simpe way is to create a batch file, put the command in it, and then double click it for ease of use.

The following code is what I use in my batch file, named say "test.bat"

You can put your JScript/JavaScript code or any other code, select appropriate Engine and run it.
This way you don't need additional baggage of the .js or .vbs file.
All in one place.

@if (@X)==(@Y) @end /* Harmless hybrid line that begins a JScript comment

:: ******* Begin batch code *********
@echo off
c:\Windows\SysWOW64\cscript.exe //E:JScript //nologo "%~f0"
exit /b

********* Begin JScript code **********/
WScript.Echo("Hooray from JScript....");

It can be tweaked further to handle multiple scenarios at run time as well.

1 Like

Thanks for the tip on the good old autoexe.bat. :sunglasses: