Just don't, was: Possible to kill just one instance of Amibroker

I have set up a batch (using the Amibroker batch function) to clear out an old watch list, load a project, run a scan, then save those to the watch list.

It saves fine within amibroker, but does not save to the underlying file unless I close Amibroker.

So at the end of my batch I load a project which basically...

ShellExecute("amibrokerkill.bat" ,"","" ,0 );

Amibrokerkill.BAT is simply

taskkill /im Broker.exe

That sucessfully terminates Amibroker. So, each day according to my criteria, a new watchlist is automaticaly set up ready for intraday trading.

The issue I see, is that if I have several instances of amibroker running, they are all terminated. So if I am running another process (e.g running a scheduled exploration), that could get killed.

How would other people approach this problem?

1 Like

This whole killing thing doesn't sound right.

When you create AB instance by object, the Application object has object.visible property that you can set to true.
AB will show the program window. If you want to close that instance, just click exit from within.

If you want to kill specific instance, you can kill by PID but how do you know which instance is which PID? unless you start tracking PIDs as instance is created.
Terminating a program like that may also have other ill effects.

Explained here:
process - On Windows, how can I gracefully ask a running program to terminate? - Super User

Ah, perfect. I’ll use the powershell Get-Process command.
Thanks for that.

Never KILL any process because you WILL lose/corrupt your data as process being killed is not given ANY chance to save anything.

Programs should be closed, not killed.

Killing is really BAD idea that can only go worse.

When you exit the room, I guess you are closing the door, not bombing it?

Besides AmiBroker has command line parameter to close itself after batch is run.

Quote from Release notes:

Example 3: load database from specified path, run batch and exit:


broker.exe /database "C:\program files\amibroker\mydatabase" /runbatch "C:\yourbatch.abb" /exit

2 Likes

Ah, ok. That makes much more sense for what I am trying to do. Thanks

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.