How to shut down Amibroker safely in cmd mode

Hello everyone,
I used taskkill /im broker.exe on the task scheduler to restart Amibroker on a daily basis, but if Amibroker is terminated normally, there will be some data storage actions, but I use taskkill and there is no storage. How can I use cmd mode to terminate normally and save the data ?

Thank you for your guidance

Hello junjun,

please see:

You have to compile a simple "Windows.exe" or execute some script via "Windows Script Host" to trigger AB via OLE.

  1. Declare AB Object
  2. Call AB.SaveDatabase()
  3. Call AB.Quit()

Search this forum for "OLE" or start with document:


  1. Create script file ABSaveDBQuit.js
var oAB = WScript.CreateObject("Broker.Application"); 
  1. Execute via CMD
cscript ABSaveDBQuit.js
1 Like

Thanks for Reply

I try the code :

var oAB = WScript.CreateObject("Broker.Application"); 

This will reopen an Amibroker program instead of the Amibroker program I am currently running

Hello junjun,

i cannot confirm to this behavior. This happens only in any case of "Broker.exe" is not running/loaded just in time you execute this script. So your current AB instance is registered by some other process name/instance.

Please check in Windows taskmanager "Broker.exe" is loaded correct and verify your program version.


regards, Peter

CreateObject only starts the program if it is NOT running already. If instance is already running, CreateObject call will attach to already running instance. It does not create new, unless:

  1. you have both 32-bit and 64-bit versions installed in separate folders
  2. you are calling CreateObject from 32-bit and already running is 64-bit AmiBroker or vice versa


for the details.


I think it should be the second reason mentioned by Tomasz. The bit version is different. I will test it again.

According to the above statement, I tested it several times and found that it does not seem to be a problem with the 32/64 bit version. It is because my computer needs to test its own plugin dll, so the computer has the latest version of 6.35.1( 64bit) and 6.10(64bit) two Amiboker programs, caused by

but. I retried a few times later and found that it can work again. Let me test it in detail and explain the situation to you.