How to start a batch ( from tools

What must be typed in into the Command / Arguments / Initial directory fields in order to start by click from the tools menu. This has for me the advantage I even can create a Keyboard short cut to start it much faster as I need some calculations been done every time I import data.
Documentation is not really helpful here.
Thanks in advance.

First of all, do you really need using custom tools for that? As it was written in the docs: batch has Import quotation option:

Importing quotation data from ASCII files

DataImportASCII command allows to automate imports via batch. The parameter is file name to be imported. The importer uses file extension to determine format file used, so if you are importing File.aqh then aqh.format definition file will be used automatically. Import would fail if corresponding definition file does not exist in the "Formats" subdirectory.

So you can sequence importing data and running your next task(s) in one batch.

Another quote from the Batch documentation:

It is possible to start the batch programmatically from AFL. The ShellExecute function in AmiBroker 6.20 supports "runbatch" command.

if( ParamTrigger("batch", "run me" ) )
    ShellExecute("runbatch", "", "" );

So (among other possibilities) you can use ParamTrigger, GuiButton or Custom Tools to run your batch. I've provided some examples of defining new Custom Tools in this thread:


I also had the same question: how to start a batch from a menu option or icon.

Any number of messages in the forum insist that we examine the earlier replies carefully since most questions have been answered before. So, I spent a lot of time trying to find a solution.

I now have an AFL which contains a GUIbutton. The button resides on a chart. When clicked, the button starts the batch file. For me, this is enough!
Here is the code (picked up from the forum):

idMyFirstButton = 1;
idMySecondButton = 2;

function CreateGUI()
     GuiButton( "update 5min", idMyFirstButton, 10, 60, 100, 30, notifyClicked );
     GuiButton( "update 30min", idMySecondButton, 110, 60, 100, 30, notifyClicked );

function HandleEvents()
   for ( n = 0; id = GuiGetEvent( n, 0 ); n++ ) // get the id of the event
         code = GuiGetEvent( n, 1 );

         switch ( id )
             case idMyFirstButton:
             // run batch
             ShellExecute("runbatch", "C:\\Program Files\\AmiBroker\\Scripts\\", "" );

             case idMySecondButton:
             ShellExecute("runbatch", "C:\\Program Files\\AmiBroker\\Scripts\\", "" );
             //   break;




Just to clarify, I picked up the button code from the online help and the shellexecute segment from a message by Milosz in this thread.

Bumped this to see if OP's original question might get answered, meaning if it is possible to start a batch from a custom tool, and if so, how to populate the custom tool fields (command, arguments, initial directory). My use case is different from OP's; I just want a custom button (already installed) on the tool bar that would run a simple batch (already created) to copy the exploration results to a watchlist whenever desired.

I have searched the batch documentation and this forum extensively, and am already aware of the following:

  1. The copy operation can be completed using the right-click contextual menu of the analysis tab
  2. A batch file can be executed by shell execution from within an AFL, a custom GUI button (as shown above), a command line batch file, and that it cannot be done via OLE.

I do have a solution (scripted macro in WinBatch called by the custom tool button ) that (mostly) works, but it's not as elegant as calling the batch directly from the custom tool would be. Personally, I think this would be a really handy tool to use when working with batch files.


New version will support extra build-in command #runbatch that will allow to run batch from Tools menu. (Worth noting is that it is in addition to already existing #import command)



Great news! Thanks Tomasz.